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

后端 未结 14 2136
情歌与酒
情歌与酒 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:11

    It can be done without printing magic strings and using TextFinder. Here's some info on it.

    Basically you need a .jar file from http://yourserver.com/cli available in shell scripts, then you can use the following command to mark a build unstable:

    java -jar jenkins-cli.jar set-build-result unstable
    

    To mark build unstable on error, you can use:

    failing_cmd cmd_args || java -jar jenkins-cli.jar set-build-result unstable
    

    The problem is that jenkins-cli.jar has to be available from shell script. You can either put it in easy-to-access path, or download in via job's shell script:

    wget ${JENKINS_URL}jnlpJars/jenkins-cli.jar
    

提交回复
热议问题