我正在使用 Jenkins“可扩展选择”插件来使用 AWS RDS 数据库实例名称列表填充参数。
在“选择提供者”中,我选择了“系统常规选择参数”。
这是应该返回数据库列表的常规代码:
//Create buffer to capture command's Standard Out
def sout = new StringBuffer(), serr = new StringBuffer()
//Define here the shell command you would like to execute
def proc = 'aws rds describe-db-instances | grep DBInstanceIdentifier | grep -v Read | awk "{print \$2}" | sed "s/\"//g"'.execute()
//Capture command output into buffer
proc.consumeProcessOutput(sout, serr)
//Time to wait for command to complete
proc.waitForOrKill(1000)
//Converts command output to a list of choices, split by whitespace
return sout.tokenize()
如果我在 shell 中运行命令,我会正确地得到输出:
[ec2-user@jenkins.company.com ~]$ aws rds describe-db-instances | grep DBInstanceIdentifier | grep -v Read | awk "{print \$2}" | sed "s/\"//g"
company
company-dev-70-mysql
dev-rds-2017-10-02
company-check-woocommerce
prod
但是当我运行该作业时,下拉菜单保持为空。
知道我做错了什么吗?