I have a use case where we need to list environments to run a pipeline over and we have multiple jenkins servers that handle different environments.
jenkins1 handles dev1 dev2 dev3
jenkins2 handles prod1 prod2 prod3
I want to be able to setup a pipeline that sources different envs and shows them as a choice field.
Try one was setting a global env var in the jenkins config like
ENVS="dev1\ndev2\ndev3"
when I did
pipeline {
parameters {
choice(choices: "${env.ENVS}", description: 'What Environment?', name: 'env')
}
}
It removed the \ so it shows it as a single choice as dev1ndev2ndev3
I'd also be open to having it read a file outside the workspace where ansible can put like /etc/env_list and the pipeline can read that file in but I wasn't haven't any luck with that.
I'm open to trying anything to make it work!
Thanks!