How to mark a build unstable in Jenkins when running shell scripts

后端 未结 14 2138
情歌与酒
情歌与酒 2020-11-27 11:31

In a project I\'m working on, we are using shell scripts to execute different tasks. Some are sh/bash scripts that run rsync, and some are PHP scripts. One of the PHP script

14条回答
  •  迷失自我
    2020-11-27 12:08

    I thought I would post another answer for people that might be looking for something similar.

    In our build job we have cases where we would want the build to continue, but be marked as unstable. For ours it's relating to version numbers.

    So, I wanted to set a condition on the build and set the build to unstable if that condition is met.

    I used the Conditional step (single) option as a build step.

    Then I used Execute system Groovy script as the build step that would run when that condition is met.

    I used Groovy Command and set the script the following

    import hudson.model.*
    
    def build = Thread.currentThread().executable
    build.@result = hudson.model.Result.UNSTABLE
    
    return
    

    That seems to work quite well.

    I stumbled upon the solution here

    http://tech.akom.net/archives/112-Marking-Jenkins-build-UNSTABLE-from-environment-inject-groovy-script.html

提交回复
热议问题