Jenkins - how to build a specific branch

前端 未结 6 2078
一向
一向 2020-11-28 23:46

This isn\'t as simple as just doing a parametrized build. I\'ve already got a specific build process that will build and deploy whenever any of these branches are pushed to

6条回答
  •  一生所求
    2020-11-29 00:12

    I can see many good answers to the question, but I still would like to share this method, by using Git parameter as follows:

    When building the pipeline you will be asked to choose the branch:

    After that through the groovy code you could specify the branch you want to clone:

    git branch:BRANCH[7..-1], url: 'https://github.com/YourName/YourRepo.git' , credentialsId: 'github' 
    

    Note that I'm using a slice from 7 to the last character to shrink "origin/" and get the branch name.

    Also in case you configured a webhooks trigger it still work and it will take the default branch you specified(master in our case).

提交回复
热议问题