Abort current build from pipeline in Jenkins

后端 未结 7 1381
时光说笑
时光说笑 2020-12-02 13:06

I have a Jenkins pipeline which has multiple stages, for example:

node(\"nodename\") {
  stage(\"Checkout\") {
    git ....
  }
  stage(\"Check Preconditions         


        
7条回答
  •  不知归路
    2020-12-02 13:42

    You can mark the build as ABORTED, and then use the error step to cause the build to stop:

    if (!continueBuild) {
        currentBuild.result = 'ABORTED'
        error('Stopping early…')
    }
    

    In the Stage View, this will show that the build stopped at this stage, but the build overall will be marked as aborted, rather than failed (see the grey icon for build #9):

提交回复
热议问题