Jenkins job failed but Octopus step shows task success

Hi ,

I am Prabhjot and working on Octopus. I am using Jenkins - Queue job step from community step.
Everything is working fine but even if the Jenkins job fail Octopus shows it as passed. Do I need to add any more step to get the Jenkins job status in Octopus.


Hi @prabhjotkour.91,

Thanks for reaching out, I’m sorry that the step isn’t working as you would expect. I just had a quick look at the community step template that you are using.

The reason it may not be ‘failing’ the job is because in the source code, it looks to be using this logic:

    if ($failBuild) {
        if ($result -ne "SUCCESS") {
            Write-Host "BUILD FAILURE: build is unsuccessful or status could not be obtained."
            exit 1

The problem with that code is, it will “Write-host” on failure. If you are receiving the message regarding “Build Failures” you should be able to update the “Write-host” command to “Write-error”, which will cause Octopus to fail the step. For more information, check out this documentation

Let me know how that goes.


Hi Dane - thanks for your reply but it’s not clear to me. Do we have functionality in octopus to check the status of Jenkins job automatically and behave pass or fail accordingly. If not do we have to add extra functionality within our Jenkins groovy code?

Hi @prabhjotkour.91,

There isn’t anything built into Octopus that would probe the Jenkins Server however you still have some options.

First of all, if it’s just the build result you’re after, a simple api call could suffice. You can get the latest documentation on your specific version of Jenkins via built in documentation available at ‘https://YOUR_JENKINS_SERVER:8080/job/A_VALID_JOB/api/’

You may get some more ideas from this BLOG post.

To clarify, once you determine the call to the api for the build you are chasing - you would be able to make the call from a Script step using Powershell (or whatever language you want). You would then set the result as an Octopus Variable.

You would then be able to determine if you want your next Octopus step to run or not using a conditional run value.

Alternatively, we have a recommended approach, but it may not be possible for your pipeline/implementation. It would be to push the Build Information to Octopus from Jenkins itself. Your final Jenkins step for the project could be to ‘Push Build Information’ or ‘Push the Package’ (if an package is created) to your Octopus Server or your Package repository. This means Octopus would only be able to act upon ‘successful’ builds. I won’t go into too much detail, because it might not be the right option for you, however if you want more information, please check out this page.

I’m sorry this wasn’t the answer you were chasing, but hopefully it will provide some valid options for you.



Hi Dane,

Thanks for suggesting the steps.

So if I don’t use Jenkins - queue step and instead use script step and add the below attached bash script will it work or I need to do any changes in this code.

Please let me know.