Jenkinsfile and different strategies for branches

前端 未结 7 1747
星月不相逢
星月不相逢 2021-01-31 03:23

I\'m trying to use Jenkins file for all our builds in Jenkins, and I have following problem. We basically have 3 kind of builds:

  • pull-request build - it will be me
7条回答
  •  耶瑟儿~
    2021-01-31 03:25

    You can add If statement for multiple stages if you want to skip multiple stages according to the branch as in:

    if(env.BRANCH_NAME == 'master'){
         stage("Upload"){
            // Artifact repository upload steps here
            }
         stage("Deploy"){
            // Deploy steps here
           }
         }
    

    or, you can add it to individual stage as in:

    stage("Deploy"){
      if(env.BRANCH_NAME == 'master'){
       // Deploy steps here
      }
    }
    

提交回复
热议问题