Reputation: 29669
I have a Jenkins slave ( at localhost:8000 ) and I am executing it ( link ) from a Jenkins Master ( at localhost:8080 ). The basic idea here is to run the remote job and wait until the job is finished.
java -jar jenkins-cli.jar -s http://localhost:8000 build "Test Suite"
Right now, this doesn't wait. I starts the job on the slave and the Jenkins Master says the task is immediately finished although the slave runs for another 30 minutes.
Does anyone know how I can block or check for a signal on the slave to verify it is finished and get the exit status code of the job?
NOTE: My slave test MUST run on the slave because it won't run from Jenkins master, which runs as a service and doesn't allow permissions to start a webbrowser from the test. So, I run the slave in a visible console.
Upvotes: 3
Views: 5559
Reputation: 104
Each windows application returns an exit code to it's parent. Examine the exit code using a windows batch file. Example:
java -jar jenkins-cli.jar -s http://127.0.0.1:9090 build "Test Suite" -s
echo The exit code is %errorlevel%
On successfull job completion you will get:
Completed "Test Suite" #72 : SUCCESS
The exit code is 0
Examine some error scenarios (wrong job name, job creates FAILED and so on)
Note: Running master jenkins not as windows service may be more easy.
Upvotes: 1
Reputation: 104
java -jar jenkins-cli.jar -s http://localhost:8000 build "Test Suite" -s
Adding the parameter -s
to the build command should trigger the job and return after job is completed
Upvotes: 5