【问题标题】:Executing a AWS KMS command with Groovy in a Jenkins Active Choice Reactive Parameter在 Jenkins Active Choice Reactive 参数中使用 Groovy 执行 AWS KMS 命令
【发布时间】:2019-04-16 14:21:56
【问题描述】:

我正在尝试使用 Jenkins Active Choice Reactive Parameter 并使用 Groovy 运行 aws kms cli 命令,但该值似乎没有返回。我查看了其他几篇关于在 Groovy 中使用 aws cli 的帖子,但没有一篇能解决我的问题。我无论如何都不是 Java 开发人员,所以欢迎任何帮助。如果我将下面的代码与“ls”命令一起使用,则该值将填充到参数中。

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]

提前感谢您的帮助

【问题讨论】:

  • 这对我在 Jenkins 中不起作用,我看到了那个帖子并尝试了他们的建议
  • 请添加您从该答案中尝试过的内容。您的代码无法使用普通的 groovy 执行,因为它使用了 shell 的功能。并且您得到代码的任何错误似乎都被忽略了。
  • 如果您需要提示,如何阅读标准错误等:stackoverflow.com/a/33089101/3181392
  • 我发现了我的错误。

标签: jenkins groovy


【解决方案1】:

我使用Run a compound shell command from Java/Groovy 中的以下内容发现了这一点。感谢@cfrick 的上述评论。

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]

【讨论】:

    猜你喜欢
    • 2016-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-24
    相关资源
    最近更新 更多