Reputation: 79
Currently one of our Jenkins builds fails. I would like it to pass (or show green) when the build fails. At the same rate i would like our build to fail (or show red) when a case passes. The build I am configuring is our “Known Issues Build”. So only failed cases go in there. The goal of this build is for it to pass when it fails, since we know it’s broken. When our devs fix it the build should fail (which means something is working now) so that we may move it out of the build into our core build. I read an article on the --wip switch and have successfully configured that into our build. I have been receiving emails that say Jenkins build is back to normal, which to me seems like it worked. However, when you look in the build itself it looks as if it fails. The build is flagged as red, which means it failed, and the tests say they failed. The only indicator they passed is the email I receive. But this is not the intended behaviour i am going for. The build seems to alert me that it passes but looks as if it fails. Is there a way i can make the red button go green, so when we look at our builds, we know when something is wrong.
Right now I added || exit 1
to the end of my command which is supposed to reverse the failed and passed flags. I also created a short bash script to reverse the button color, which also did not work. I believe i am missing something. Any ideas? Listed below is the command I am running to launch our build:
cucumber --wip --profile wip --format json -o cucumber.json /var/lib/jenkins/workspace/Cucumber\ -\ Known\ Issues\ Build/ SITE=devel || exit 1
Upvotes: 1
Views: 4241
Reputation: 27485
command || exit 1
means "If command
failed, then exit 1
(i.e with failure)
You just said that you want build to fail if your command was successful, so you need:
command && exit 1 || exit 0
Above, if command
is successful, then build is marked as failed, else (if command
was not successful), mark the build as success
Here is the console output for the job:
Started by upstream project "Cucumber - Devel Parent Build" build number 58
originally caused by:
Started by timer
Xvfb starting$ /usr/bin/Xvfb :75 -screen 0 1024x768x24 -fbdir /var/lib/jenkins/2013-01-25_22-24-203386303931627225842xvfb
Building remotely on dev548 in workspace /var/lib/jenkins/workspace/Cucumber - Known Issues Build
Checkout:Cucumber - Known Issues Build / /var/lib/jenkins/workspace/Cucumber - Known Issues Build - hudson.remoting.Channel@322535f5:dev548
Using strategy: Default
Last Built Revision: Revision f48428cc3128a0d6369ea99bbdbdf419bc29b173 (Cucumber/master)
Fetching changes from 1 remote Git repository
Fetching upstream changes from [email protected]:/cucumber.git
Commencing build of Revision dad2f8792ec364e79dd76840f787d5e72676b03f (Cucumber/master)
Checking out Revision dad2f8792ec364e79dd76840f787d5e72676b03f (Cucumber/master)
Deleting old artifacts from #137
[Cucumber - Known Issues Build] $ /bin/bash /tmp/hudson3196742906607332265.sh
Using the wip profile...
Xvfb stopping
Archiving artifacts
[CucumberReportPublisher] Compiling Cucumber Html Reports ...
[CucumberReportPublisher] detected this build is running on a slave
[CucumberReportPublisher] copying json from: file:/var/lib/jenkins/workspace/Cucumber%20-%20Known%20Issues%20Build/to reports directory: file:/var/lib/jenkins/jobs/Cucumber%20-%20Known%20Issues%20Build/builds/2013-01-25_22-24-20/cucumber-html-reports/
[CucumberReportPublisher] Generating HTML reports
Build step 'Publish cucumber results as a report' marked build as failure
Notifying upstream projects of job completion
Finished: FAILURE
This is the build steps in my configuration:
#!/bin/bash
source /usr/local/rvm/environments/default
/usr/local/rvm/gems/ruby-1.9.2-p320/bin/cucumber --profile wip --format json -o cucumber.json /var/lib/jenkins/workspace/Cucumber\ -\ Known\ Issues\ Build/ SITE=devel && exit 1 || exit 0
Upvotes: 2