Answer the question
In order to leave comments, you need to log in
How to create ami list in jenkins using extendedChoice parameter?
It works:
steps {
script {
def images_ls_output = sh(script: "aws ec2 describe-images --query Images[*].[Name] --owner 111111111111 --region us-east-2 --output=text", returnStdout: true).trim()
println "${images_ls_output}"
def image = images_ls_output.tokenize().reverse()
println "${image}"
}
}
parameters {
extendedChoice(
bindings: '',
defaultValue: 'build',
description: '',
groovyClasspath: '',
groovyScript: '''
def app_filter = "api.tar"
def s3_path = "s3://wpl-artifactory/"
def aws_s3_ls_output = "aws s3 ls ${s3_path} --region us-east-2".execute() | [\'sort\', \'-k 1\'].execute() | "grep ${app_filter}".execute() | [\'awk\', \'{ print $NF }\'].execute()
def files = aws_s3_ls_output.text.tokenize().reverse()
return files
''',
multiSelectDelimiter: ',',
name: 'BUILD_VERSION',
quoteValue: false,
saveJSONParameterToFile: false,
type: 'PT_SINGLE_SELECT',
visibleItemCount: 5
)
}
parameters {
extendedChoice(
bindings: '',
defaultValue: 'build',
description: '',
groovyClasspath: '',
groovyScript: '''
def images_ls_output = sh(script: "aws ec2 describe-images --query Images[*].[Name] --owner 11111111 --region us-east-2 --output=text" returnStdout: true).trim()
def image = images_ls_output.tokenize().reverse()
return image
''',
multiSelectDelimiter: ',',
name: 'USE_EXISTING_IMAGE',
quoteValue: false,
saveJSONParameterToFile: false,
type: 'PT_SINGLE_SELECT',
visibleItemCount: 5
)
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question