0

I'm trying to use a Jenkins Active Choice Reactive Parameter and using Groovy to run an aws kms cli command, but the value doesn't seem to be returning. I've looked at the couple other posts around using aws cli in Groovy but none of them resolve my issue. I'm not a Java developer by any means so any help is welcomed. If I use the code below with a "ls" command then the value is being populated in the parameter.

Yo
def command = "aws kms decrypt --query Plaintext --output text --ciphertext-blob fileb://<(echo 'my-cipher' | base64 -d') | base64 -d".execute()
command.waitFor()
return [command.text]

Thanks in advance for any help

  • 1
    Possible duplicate of [Run a compound shell command from Java/Groovy](https://stackoverflow.com/questions/34503307/run-a-compound-shell-command-from-java-groovy) – cfrick Apr 16 '19 at 14:32
  • This does not work for me in Jenkins, I saw that post and tried what they suggest – balistikbill Apr 16 '19 at 16:07
  • Please add what you have tried from that answer. Your code there wont work with plain groovy execute, because it uses features of the shell. And any error you get your code seems to ignore. – cfrick Apr 16 '19 at 16:11
  • If you needs hints, how to read the stderr etc: https://stackoverflow.com/a/33089101/3181392 – cfrick Apr 16 '19 at 16:12
  • I figured it out my mistake. – balistikbill Apr 16 '19 at 16:57
  • Then feel free to add an answer, how you fixed your problem, as it might help others – cfrick Apr 16 '19 at 16:59

1 Answers1

1

I figured this one out using the below from Run a compound shell command from Java/Groovy. Thanks to @cfrick for the comment above.

def out = ['bash', '-c', "aws kms decrypt --query Plaintext --output text --ciphertext-blob fileb://<(echo 'my-cipher' | base64 -d) | base64 -d"].execute([], new File('/tmp')).text

return [out]