One way would be for your first job to set an environment variable with the list of recent built image tabs (one per line).
See declarative pipeline environment
directive.
Then, following "Dynamic Parameter in Jenkinsfile?", you can use an external function like:
#!/bin/groovy
def envs = loadEnvs();
properties([
parameters([
choice(choices: envs, description: 'Please select an image tag', name: 'Env')
])
])
That should be enough to build a choice parameter list.
"Pipeline: How to manage user inputs " (May 10th, 2017, two weeks ago) shows an alternative command, but not valid in the Declarative Pipeline syntax:
You have to use the input
step to achieve it.
It will give you something like this :
stage 'promotion'
def userInput = input(
id: 'userInput', message: 'Let\'s promote?', parameters: [
[$class: 'TextParameterDefinition', defaultValue: 'uat', description: 'Environment', name: 'env'],
[$class: 'TextParameterDefinition', defaultValue: 'uat1', description: 'Target', name: 'target']
])
echo ("Env: "+userInput['env'])
echo ("Target: "+userInput['target'])