Madura Dissanayake
Madura Dissanayake

Reputation: 8759

How to set default value for Active Choices Reactive Parameter plugin in Jenkins?

I'm using the following Groovy code snippet for listing all the git branches in particular git repo and I can get that list successfully. But how can I set a default value for this list ? I'm trying to set master as default value.

def gettags = ("git ls-remote --heads git@org/sample-repo-service.git").execute()
def repoNameList = gettags.text.readLines().collect {
    it.split()[1].replaceAll('refs/heads/', '').replaceAll('refs/tags/', '').replaceAll("\\^\\{\\}", '')
}

Upvotes: 1

Views: 3276

Answers (1)

Madura Dissanayake
Madura Dissanayake

Reputation: 8759

Here you can use the option selected for the default value 'master:selected' and then return the list.

def gettags = ("git ls-remote --heads [email protected]:org/sample-repo-service.git").execute()
def repoNameList = gettags.text.readLines().collect {
    it.split()[1].replaceAll('refs/heads/', '').replaceAll('refs/tags/', '').replaceAll("\\^\\{\\}", '')
}
repoNameList.add(0, 'master:selected')
return repoNameList

Upvotes: 2

Related Questions