Last active
December 19, 2022 15:56
-
-
Save sudharsans/620628fcc36469360c2981fd9215e5d2 to your computer and use it in GitHub Desktop.
Groovy, AWS CLI, Active Choices Reactive Parameter and Jenkins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://stackoverflow.com/questions/48982349/query-aws-cli-to-populate-jenkins-active-choices-reactive-parameter-linux | |
// Get list of IPS from AWS CLI and populate Active Choices Reactive Parameter | |
def command = 'aws ec2 describe-instances --filters Name=tag:Name,Values=Test --query Reservations[*].Instances[*].PrivateIpAddress --output text' | |
def proc = command.execute() | |
proc.waitFor() | |
def output = proc.in.text | |
def exitcode= proc.exitValue() | |
def error = proc.err.text | |
if (error) { | |
println "Std Err: ${error}" | |
println "Process exit code: ${exitcode}" | |
return exitcode | |
} | |
//println output.split() | |
return output.tokenize() |
try this -
def command = 'aws ec2 describe-instances --filters Name=tag:environment,Values=CF-LAB --query \'Reservations[*].Instances[*].{ID:InstanceId,NAME:[Tags[?Key==
Name].Value[] | [0]]}\' --output text'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm having an issue when I introduce the tag key, like so
It looks like a syntax issue, but I cannot figure out why. any idea?
Thanks