Jenkins Active选择参数,如何使用groovy执行aws shell命令 [英] Jenkins Active choice parameter, how to execute aws shell command with groovy
本文介绍了Jenkins Active选择参数,如何使用groovy执行aws shell命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在管道启动之前获取所有应用程序版本,这就是为什么我创建Active选择参数然后编写脚本以从AWS获取所有应用程序版本的原因.但是经过一些测试,我得到了一个错误:
Hi I need to get all my app versions before pipeline starts, that is why i create Active choice parameter then write a script that will get all app versions from aws. But after some tests I get an error:
java.io.IOException: error=2, No such file or directory
这是我的脚本:
def region = "us-east-1"
def appName = "My app"
def command = "aws elasticbeanstalk describe-application-versions --application-name \"${appName}\" --region ${region}"
Process process = command.execute()
def out = new StringBuffer()
def err = new StringBuffer()
process.consumeProcessOutput( out, err )
process.waitFor()
if( out.size() > 0 ) println out
if( err.size() > 0 ) println err
为什么会发生错误?
推荐答案
尝试将命令作为list的实例传递:
Try passing the command as an instance of list:
def command = ['aws', 'elasticbeanstalk', 'describe-application-versions', '--application-name', "'${appName}'", '--region', "'${region}'"]
这篇关于Jenkins Active选择参数,如何使用groovy执行aws shell命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文