Jenkins Dynmaic Parameter - List All Branches in a Git Repository
The below code lists all the branches from a Git Repo as a drop down in jenkins. proc1 = ['/bin/bash', '-c', "git ls-remote -h ssh://ssh@<GitURL>/<projectkey>/<RepoName>.git"].execute() proc2 = ['/bin/bash', '-c', "awk '{print \$2}'"].execute() proc3 = ['/bin/bash', '-c', "sed s%^refs/heads%origin%"].execute() all = proc1 | proc2 | proc3 String result = all.text def values = result.tokenize() return values Steps to Add this code. 1. Login to Jenkins 2. Go to your Job Configuration 3. Select this Project is Parameterized 4. Select Active Choices Reactive Parameter 5. Click on Radio Button Groovy Script 6. Add the above code. 7.Save the Job. Examples: <GitURL> : ssh://ssh@ bitbucket.com:7999 <projectkey>: sm <RepoName>: MyTestRepo
Comments
Post a Comment