I want to create an input step that prompts the user to select a git tag. To do this, I want to populate a dropdown box with the values returned by git tag
.
Here is my current pipeline:
pipeline {
agent any
stages {
stage('My Stage') {
input {
message "Select a git tag"
parameters {
choice(name: "git_tag", choices: TAGS_HERE, description: "Git tag")
}
}
steps {
echo "The selected tag is: ${git_tag}"
}
}
}
}
I would like TAGS_HERE to be a variable or method that contains the output given by the git tags
command.
So far I have tried:
- Setting the tags to an environment variable in a previous step - doesn't work because these variables are for some reason not accessible in the input block
- Calling a seperate groovy method that runs the command and returns the output - doesn't work because the workspace is lost and the commands are all run in
/
I have searched extensively for a solution but all the examples I can find avoid these two pitfalls by either exclusively using scripted pipeline steps or by using commands that are not workspace dependant.