Is it possible to have a bash script Jenkins job report Red, Amber, and Green? - bash

I have a couple of bash scripts running on Jenkins which return 0 and 1 exit codes depending on their outcome and the Jenkins job shows as green and red, respectively.
We have other Jenkins jobs which sometimes go amber. What exit code do I need to return to get that from a bash script?

The "Execute Shell" build step has an Advanced button.
Click on it and you can enter the exit code that Jenkins will interpret as "unstable".

Related

In Travis, is it possible to mark a staged as "Cancelled" instead of "Failed" when running a bash script?

There does exist a "Cancelled" state, which you can invoke by clicking on small x next to the job. This is how a cancelled job looks:
Is it possible to enter this cancelled state when running a bash script invoked by your .travis.yml? From Travis docs:
If script returns a non-zero exit code, the build is failed
So returning a different error code doesn't help. Is it just not doable?

bash: stop subshell script marked as failed if one step exits with an error

I am running a script through the SLURM job scheduler on HPC.
I am invoking a subshell script through a master script.
The subshell script contains several steps. One step in the script sometimes fails because of the quality of the data; this step is not required for further steps, but if this step fails, my whole subshell script is marked with "failed" Status in the job scheduler. However, I need this subshell script to have a "completed" Status in the Job scheduler as it is dependency in my master script.
I tried setting up
set +e
in my subshell script right before the optional step, but it doesn't seem to work: I still get an exitCode with errors and FAILED status inthe job scheduler.
In short: I need the subshell script to have Status "completed" in the job scheduler, no matter whether one particular step is finished with errors or not. Will appreciate help with this.
For Slurm jobs submitted with sbatch, the job exit code is taken to be the return code of the submission script itself. The return code of a Bash script is that of the last command in the script.
So if you just end your script with exit 0, Slurm should consider it COMPLETED no matter what.

How to display bash script execution on Jenkins Console from Cygwin

Calling the below bash script from Jenkins pipeline but I don't see the script execution on Jenkins console, can someone please advise how to display execution on jenkins console, bash script execution which is running on cygwin(on windows agent)
bat'call D:\cygwin64\bin\mintty.exe /usr/bin/bash -lic \"/home/test.sh\" '
One possible way to accomplish this is to go to "Manage Jenkins", "Configure System", and change the "Shell executable" parameter to your cygwin bash address. As your example shows, something like D:\cygwin64\bin\bash.exe. Then, on the job configuration, you can select on "Build", "Execute Shell". You can paste your test.sh script content in there. Like this:
With this configuration, Jenkins will run whatever you pasted in the "Execute shell" screen using the bash.exe address you provided in the configuration. I believe this is the most seamless way to execute shell scripts on Jenkins running on windows. The output looks almost Linux native:

Mark as successful action for builds in Teamcity

I have a question to all the experienced Teamcity users out there.
I would like to exit out of a job based on a particular condition, but I do not want the status of the job as a failure. Is it possible to mark a job as successful even when you exit out of the job with an "exit code 1" or any pointers to achieve the same (exit out of a Teamcity job but mark the job as successful) through an alternative way is greatly appreciated!
Thanks!
You can use TeamCity service messages to update build status, e.g. write to the output
##teamcity[buildStatus status='SUCCESS' text='{build.status.text} and then made green']
to get build status text concatenated with the and then made green string.
If you have Command Line Build Step and you are using TeamCity 2017.2 then you can format stderr output as warning. Here is a documentation: https://confluence.jetbrains.com/display/TCD10/Command+Line

Jenkins trigger conditional build steps in shell?

I am using Jenkins as a server to run cron jobs that are conditional on the success of other jobs. These can be run as multiple execute shell steps. I am specifically wondering if there is a way to make an execute shell step contingent on the exit status of the previous execute shell step.
This is the default behaviour. Each build step, such as "Execute Shell" step, returns an exit code (last command). If that is 0, the next build step is executed. If that is not 0, Jenkins "FAILS" the build, and skips straight to post-build steps.
If your shell returns 0 on success, and everything else is a failure, just put several "Execute Shell" build steps one after another.

Resources