Hudson job running as wrong user - jenkins

I have a Hudson build job which runs a script called 'testUser.sh' which contains only one command: 'whoami'. The first line of the console output says 'Started by user ctisbuild', but the output of the whoami/testUser.sh script is 'root'.
Any idea what's going on? This used to be working properly, I don't know what changed to cause this.
Thanks

I guess you are running hudson as root from the command line? Using java -jar hudson.war?
The "Started by user ctisbuild" is the user if of the user that trigger the build, the person who clicked on "Build Now". This is not the userid that Hudson will use. This user id is specified in the /etc/default/hudson as HUDSON_USER
For more details read the hudson wiki

Related

How to start Owasp zap server(exe or jar) from jenkins

Actually, the main issue is if I start the server then my next commond will never trigger as it always running as zap server in listening mode.
Can I run two command line in Jenkins. I have added 2 "Execute Windows batch command" still nothing works. I have added the image in same thread
I have tried by creating a batch file
cd /
cd C:\Program Files\OWASP\Zed Attack Proxy
start java -jar zap-2.6.0.jar
I am getting error as below after using above batch file
Process leaked file descriptors. See https://jenkins.io/redirect/troubleshooting/process-leaked-file-descriptors for more information
https://wiki.jenkins.io/display/JENKINS/Spawning+processes+from+build
I have also use command line arugument directly in "Execute window batch command" like:-
java -jar zap-2.6.0.jar
But the UI of zap is not starting
I have also tried "Windows Exe Runner Plugin"
https://wiki.jenkins.io/display/JENKINS/Windows+Exe+Runner+Plugin
But jenkins not allowing me to put an exe name in configuration. Looks like a bug of jenkins.
I have also tried by adding zap in environmental variable but that also not working.
Now I am out of idea.
The issue is if I am triggering zap.bat it will do not allow another command to run forward as below which is in my batch:-
Additionally, UI of zap is not open as it is open after direct clicking on zap.bat file
I have added 2 "Execute Windows batch command" still nothing works
Any suggestions will be welcome
Simple - dont start it from the jar!
Start it using the zap.sh or zap.bat scripts we provide as part of the installation :) You'll also probably want to use the -daemon flag.
Or you can use the official ZAP jenkins plugin: https://wiki.jenkins.io/display/JENKINS/zap+plugin
I have resolve this issue by creating two jobs in jenkins.
The main job trigger the first job.
Follow the steps :-
Go to the configure section of main job
Now add "Trigger/call builds on other projects" from Build option
Add the project name of zombie job
Note :- uncheck the checkbox of "Block until the triggered projects finish their builds".

Console output while running Jenkins

I am using Jenkins. I can see console output for jobs that have finished. But, how do I view the console out for Jenkins jobs that are in progress?
I think the question is how to see the output of the individual job, not the Jenkins system log. You can view console output of a job in progress by going to the page for that job in Jenkins and clicking on the colored ball for that job. The running build will have a flashing ball, while the completed jobs will not be flashing. In addition, you can click on the progress bar for a running job to see the console output.
The answer to this question very much depends on how you are running Jenkins. For example first example in the starting Jenkins guide demonstrates the following:
$ nohup java -jar jenkins.war > $LOGFILE 2>&1
Here you explicitly send the console output to a file. The problem is that there are lots of other ways to run Jenkins, so you are probabily better off configuring logging:
https://wiki.jenkins-ci.org/display/JENKINS/Logging
This will work if Jenkins is deployed inside a container like tomcat.
Update
The system log is available from the "Manage Jenkins" -> "System Logs" screen. It contains most of what will appear on the console:
http://<hosthname>:<portnumber>/log/all
You can view the console output for Jenkins jobs that are in progress by the following two steps below:
On Build History click on the progress bar.
Click to see
On the next window click on the Console Output to see the console output.
Click to see

Jenkins logs for a perl build file

Today I started working with jenkins and I successfully added my projects to jenkins and it says all works fine . one of the build takes more than 5 hours but didn't finish either so aborted it(while manual build takes less than 1 hour).. and while i tried to check with the log the log was not detailed. so i tried to get the logs of the perl script by running it as a shell command
usr/local/bin/perl perlscript.pl>logfile.txt
there was no log written and there was no evidence of the build triggered either cases.i'm not aware of what the problem is as both the perlscript(works fine while manually triggered) and jenkins are working properly except this project. I would like to have your help.thanks in advance
A few things you should understand about Jenkins:
Jenkins shows STDOUT as the log of the Job,
so if you redirect it to a file - nothing will be shown in the log.
Depending on how you have set it up, Jenkins may run as its own user,
which may change the behavior of your scripts.
You can confirm this by echo-ing the username at the beginning of your Execute Shell block,
for example:
echo $USER
Each Jenkins-Job is run from its own workspace -
you can confirm that location by simply printing the current working directory
at the beginning of your Execute Shell block, for example:
echo my current directory is
pwd

Multi-configuration job - where is the output?

I'm a newbie to Jenkins, so perhaps it is a stupid question, but...
I'm trying to write a job that will compile my code on several UNIX nodes. I created a multi-configuration project, and add one slave to it.
The job itself is a shell that only does 'ls' and 'pwd'
The output is:
Started by user anonymous
Building on master in workspace C:\Program Files (x86)\Jenkins\workspace\Unix-third-party
Triggering Linux64
Linux64 completed with result SUCCESS
Finished: SUCCESS
But I can't see the output of the commends anywhere.
When I changed the matrix to use nodes instead of labels, I managed, to see the output, but I'm still not sure what I did.
A free-style project for the same node works with no problems.
Where do I find the output?
On your job page, you'll see a link called "default" if you have only one node/slave, or the node's name if you have more than one.
Click on that link, then click on a build and console output.
The way it works is:
-----------------config 1 -> build #X -> console output
/
Main Job build #X console output ---->
\-----------------config 2 -> build #X -> console output
What you are looking at is the console output for the main job, but this only contains trigger information. The actual output is contained in the config 1 and config 2 console outputs.
Comment if you need further clarification, and I'd be glad to help.
Btw, welcome to the world of Jenkins :-)
==========================================================================
EDIT:
The following URL should take you to yourc console output for a build where you've chosen "Label":
Substitute everything in <>.
http://<myserver>/job/<jobname>/label=<label>/<buildnumber>/console
Not sure if this will help you, however at work, to view our slave consoles, the following URL will work:
https://ci.(company).com/job/QA/job/[projectname]/13/script=loadtest1/console
I'd assume your system would be similar.
Alternatively, if i go to the main ci.(company).com/job/QA/job/[projectname]/
i can see the recent job on the left corner.
When selected that specific job, at the base of the screen is our configurations, which you select, then can view the console output of that specific job.
Viewing the main jenkins job will not output console logs from slaves.
I ran into this today, not sure what caused it, but I was able to get my build configs to show console logs and artifacts once more by deleting "builds" and "configurations" folders under "C:\Program Files (x86)\Jenkins\jobs\ProjectName".
Obviously, this also gets rid of your build history, but I just need the configs running again.

postbuild UIAutomation script not running in jenkins

I am trying to do End-to-End automation for an iOS project. My aim is to automate the continuous integration process with attaching UIAutomation scripts as post build action.
So from the time when a user do check his code in SVN and till we get test result of automation, everything will be automated.
Jenkins is installed on my local machine and running on localhost.
Now I have automated build process through jenkins and at other end I have my shell script ready which will run UIAutomation java scripts on build output.
When I use my shell script as post build action then I get error in running instrument command(written inside shell script) but if I run this script manually through terminal then it works fine.
instruments[64703:60f] -[NSAlert alertWithError:] called with nil NSError. A generic error message will be displayed, but the user deserves better.
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL. Mon Feb 6 13:15:20 inpunml310743 instruments[64703] <Error>: kCGErrorFailure: Set a breakpoint # CGErrorBreakpoint() to catch errors as they are logged. 2012-02-06 13:15:20.179 instruments[64703:60f] Recording cancelled : At least one target failed to launch; aborting run Instruments Trace Error : Failed to start trace. Build step 'Execute shell' marked build as failure Finished: FAILURE
then i tried this command with sudo then I got following error
sudo: no tty present and no askpass program specified
Please let me know how can I run these commands successful, only this step is left in my task.
Jenkins by default installs as a LaunchDaemon, which means it has insufficient permissions to launch WindowsServer.
You’ll need to configure it as a LaunchAgent:
sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
sudo mv /Library/LaunchDaemons/org.jenkins-ci.plist /Library/LaunchAgents/org.jenkins-ci.plist
Then login as Jenkins and keep a session open.
If you don't know the Jenkins password you can change it with:
sudo passwd jenkins
Jenkins is running as a daemon and is therefore not allowed to connect to the window server. More info here http://developer.apple.com/library/mac/#technotes/tn2083/_index.html.
Sorry - not got time to put a complete answer now, will update later....
This is possible if you run jenkins as a user app rather than as a deamon -- this might come in handy (https://github.com/stisti/jenkins-app) I haven't tried it but looks like it should work -- I went down another route setting up an always logged in user, that ran jenkins from a login script, it did mean I had to re-install jenkins but managed to get it up and running... word of warning from someone thats been through it, are you using instruments for automated testing? If so, you'll need to do some transformation on the output so it displays in Jenkins.
We have a Jenkins Linux instance that builds to a Mac slave over SSH. One interesting requirement that we noticed with this error is that the build user on the slave must be logged into the console in order for everything to work correctly.
In addition, we had to make the build user an Admin, developer permissions were insufficient.
See more info here:
UIAutomation : Failed to authorize rights with status: -60007

Resources