Why doesn't Jenkins stop processing after a failed build step? - jenkins

I'm running into an issue where Jenkins is continuing on to subsequent build steps even when the prior build step has failed. This is for setting up a Jenkins free-style job.
The build steps I'm running into an issue with are for "Trigger/call builds on other projects" steps, I am selecting/checking the option for "Block until the triggered projects finish their builds" and setting the parent job to mark the build result the same as the triggered jobs.
So say I have Job_1, Job_2, and Job_3 scheduled in sequence using the above options. Job_1 passes just fine, then Job_2 fails. In the Jenkins logs it shows Job_2 failing and marking the parent job as failed. However, the parent job still continues on to Job_3 even after marking itself as failed.
Here's an example from the Jenkins console output; notice how Job_2 failed and build result was changed to failure, but 1 second later Jenkins still kicks of Job_3 even though the build is already marked as failure:
12:34:54 Waiting for the completion of Job_1
12:48:44 Job_1 #7 completed. result was SUCCESS
12:48:44 Build step 'Trigger/call builds on other projects' changed build result to SUCCESS
12:48:45 Waiting for the completion of Job_2
18:18:44 Job_2 #169 completed. result was FAILURE
18:18:44 Build step 'Trigger/call builds on other projects' changed build result to FAILURE
18:18:45 Waiting for the completion of Job_3
18:38:25 Job_3 #180 completed. result was SUCCESS

It turns out the issue is with the trigger parameterized builds plug-in. For some reason they thought it would be a good idea to continue on to subsequent build steps even if a build step that is a blocking call fails and calls the invoking parent job to fail.
Looks like I gotta do things myself or switch to Bamboo...

Related

Jenkins job somtimes triggers downstream

I have some jobs which trigger each other after they finish, but in some cases, the last test3 job isn't started, and I have no error message/ideas on why?
Most of the time the build test2 writes "Triggering a new build of test3" and in some cases, it's not there? It doesn't matter if the job test2 failed or passed, and there isn't any pattern when it doesn't trigger the last job. Does anyone have some ideas on what to look at, because I'm a little lost?
All runs are triggered on: Jenkins 2.332.3
Settings:
Builds:
What can make a job not trigger the next one?

Jenkins pipeline how to detect downstream build status when using parallel()?

I have a pipeline that invokes a couple hundred runs of a downstream job in a parallel block. The downstream job contains a check that may abort the job.
How can I check the build status of the downstream jobs ran in the parallel block? Ideally, the parallel step returns the status of each downstream build in a map or something, but as far as I can tell it returns only a single build status. In my case, if downstream jobs have been SUCCESS, FAILURE, and ABORTED, the upstream build sets it's status as ABORTED.
currentBuild.status and currentBuild.currentResult both seem to have the wrong status set, and if I catch the exception thrown from the parallel step, it's just a hudson control flow exception that doesn't let me know the status of the downstream build.
What is the best way to get the correct downstream build status from jobs invoked from the parallel step?

Jenkins: Mark build as success if the last step succeded even if a previous step was unstable

I've in jenkins a flow like this:
Wrapper Job1
Trigger Job2
(Conditionally) if the job 2 is unstable it triggers the Job3
Below you can see JOB1 (wrapper) configuration pics:
JOB2 trigger configuration :
JOB3 conditional trigger configuration
Now, to give you a little bit of context:
I'm running tests with selenium and cucumber, these tests can randomly fail and if they fail, the job2 is marked unstable (if not the wrapper just finish with success status), in case the job2 fails will be triggered the job3, this is a "RERUN FAILED TESTS" task, then obviously in the case this last will be completed with success I want the wrapper to be marked as SUCCESS.
This should be really easy, but it's not working, below the wrapper (JOB1) jenkins job log:
FIRST STEP (JOB2) UNSTABLE BECAUSE SOME TESTS FAILED:
Waiting for the completion of REM_Parallel_Tag_Sub_Runner
REM_Parallel_Tag_Sub_Runner #9 completed. Result was UNSTABLE
Build step 'Trigger/call builds on other projects' changed build result
to **UNSTABLE**
IF THE JOB2 IS UNSTABLE THE WRAPPER TRIGGER THE JOB 3:
[Current build status] check if current [UNSTABLE] is worse or equals then
[UNSTABLE] and better or equals then [UNSTABLE]
Run condition [Current build status] enabling perform for step [BuilderChain]
Waiting for the completion of REM_Parallel_Sub_ReRuns
THE JOB 3 SUCCEEDED, THIS MEANT THAT THE TESTS THAT WERE FAILING NOW ARE SUCCEEDING, AND I WANT THAT THIS STEP UPDATE THE JOB1 FROM UNSTABLE TO SUCCESS, IT SHOULD BE A NORMAL BEHAVIOUR
REM_Parallel_Sub_ReRuns #6 completed. Result was SUCCESS
[CucumberReportPublisher] Compiling Cucumber Html Reports ...
[CucumberReportPublisher] Copying all json files from: /PATH/workspace /TiaCukes to reports directory: /PATH/cucumber-html-reports
[CucumberReportPublisher] there were no json results found in: /u01/app/build/jenkins/jobs/REM_Parallel_Tag_Runner_Orchestrator/builds/9/cucumber-html-reports
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
No emails were triggered.
Warning: you have no plugins providing access control for builds, so falling back to legacy behavior of permitting any downstream builds to be triggered
Finished: UNSTABLE
AS YOU CAN SEE THE BUILD STATUS HAS NOT BEEN UPDATED, EVEN IF THE LAST TRIGGERED STEP SUCCEEDED, THE BUILD STATUS REMAINS UNSTABLE
How can i fix it? Should not be so hard goal to accomplish!
Thanks a lot!
Resolved with the use of variables set by Parameterized Trigger Plugin:
https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin
Pics below:
JOB2 trigger configuration:
JOB3 conditional trigger configuration:
Feel free to ask about details

Unifying Jenkins console logs

We have a nightly build of our projects and each of them has several downstream jobs, and I configured Jenkins to send the build logs when the main job ends. The problem is that the main console only shows the details of its own job, and from the downstream jobs it shows this:
Waiting for the completion of "Project BBB"
"Project BBB" #41 completed. Result was SUCCESS
Is there any way I could make it show the details of the downstream jobs?
Started by upstream project "Project AAA" build number 38
originally caused by:
Started by user "User Name"
Building in workspace C:\WORKSPACE\Project BBB
Reverting C:\WORKSPACE\Project BBB\. to depth infinity with ignoreExternals: true
Updating https://111.111.111.111/svn/Project BBB at revision '2014-10-10T11:00:11.785 +0100'
At revision 43143
no change for https://111.111.111.111/svn/Project BBB since the previous build
Notifying upstream projects of job completion
Finished: SUCCESS
Or at least send the downstream jobs build.log also?
The build log of each completed job is available in plain text:
http://<jenkins_server>/job/<job_name>/<job_number>/consoleText
In your downstream job, you can pull this log into a file, and simply cat it out in the downstream's console log.

How to abort Jenkins job if a triggered build failes

I have a job in Jenkins which triggers another one.
How do I make the job abort if the triggered one fails?
Thanks
Gil
You can open http://$HOST/jenkins/job/$PROJECT/$BUILD/stop
Use parametrized trigger plugin from here.
Use it as a build step ("Trigger/call builds on other projects"), check "Block until the triggered projects finish their builds" box, and choose "Fail this build step if the triggered build is worse or equal to FAILURE".
You can add the post build task to the triggered job that will:
run if Finished: FAILURE found in the build log,
execute shell:
curl "$UPSTREAM_BUILD/stop" >/dev/null
$UPSTREAM_BUILD neds to be specified by parameter or you can determine it somehow using API...
I am currently setting up my matrix builds to abort all other configurations if one failed and it works as above.

Resources