Dynamically Fill Jenkins Choice Parameter With Git Branches In a Specified Repo

后端 未结 13 936
离开以前
离开以前 2020-11-29 16:41

I have a parameterized Jenkins job which requires the input of a specific Git branch in a specific Git repo. Currently this parameter is a string parameter.

Is ther

13条回答
  •  生来不讨喜
    2020-11-29 17:40

    I tried a couple of answers mentioned in this link, but couldn't figure out how to tell Jenkins about the user-selected branch. As mentioned in my previous comment in above thread, I had left the branch selector field empty.

    But, during further investigations, I found another way to do the same thing - https://wiki.jenkins-ci.org/display/JENKINS/Git+Parameter+Plugin I found this method was a lot simpler, and had less things to configure!

    Here's what I configured -

    1. Installed the git parameter plugin
    2. Checked the 'This build is parameterized' and added a 'Git parameter'
    3. Added the following values: Git Parameter plugin config in the job

    4. Then in the git SCM section of the job I added the same value mentioned in the 'Name' section, as if it were an environment variable. (If you read the help for this git parameter plugin carefully, you will realize this) Branch Selector

    After this I just ran the build, chose my branch(Jenkins checks out this branch before building) and it completed the build successfully, AND by choosing the branch that I had specified.

提交回复
热议问题