I'm trying to add a dynamic choice parameter to a Jenkinsfile with declarative syntax, using something like this:
def myChoices = listBranchesFromGithub(MY_REPO)
pipeline {
parameters {
choice(name: 'mychoice', choices: myChoices)
}
}
but listBranchesFromGithub(MY_REPO) is evaluated once (when the Jenkinsfile is processed), not everytime I run the job.
Is there a way to populate choices everytime the job is triggered?