詹金斯管道sh添加新行 [英] jenkins pipeline sh adding new line
本文介绍了詹金斯管道sh添加新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的管道被屏蔽:
sh "set +e; /terraform/terraform plan -var aws_access_key=${aws_access_key} -
var aws_secret_key=${aws_secret_key} -var aws_ami=${ami_id} -var
aws_instance_type=${instance_type} -var aws_elb_security_group=${elb_sg} -var
aws_ec2_security_group=${ec2_sg} -detailed-exitcode; echo \$? > status"
exitCode = readFile('status').trim()
echo "Terraform Plan Exit Code: ${exitCode}"
输出:
+ set +e
+ /terraform/terraform plan -var aws_access_key=**** -var aws_secret_key=**** -var aws_ami=ami-xxxxxxx
+ -var aws_instance_type=t2.medium -var aws_elb_security_group=sg-xxxx
/terraform/selectdev/int/mp-frontend@tmp/durable-6c57c14c/script.sh: line 3: -var: command not found
+ -var aws_ec2_security_group=sg-axxx
/terraform/selectdev/int/mp-frontend@tmp/durable-6c57c14c/script.sh: line 4: -var: command not found
+ -detailed-exitcode
/terraform/selectdev/int/mp-frontend@tmp/durable-6c57c14c/script.sh: line 5:
-detailed-exitcode: command not found
+ echo 127
我不确定为什么要在命令中添加新行,如果我使用sh''这样的单引号,则变量为空.我在做什么错了?
I'm not sure why new line is being added to the command and If I do single quotes like sh '', variables are blank. what am I doing wrong ?
我试图做下面的事情,但是它也增加了新的行
I tried to do like below but it too adding new lines
def command = $/....../$
res = sh(returnStdout: true, script: command)
推荐答案
我正在使用的变量来自其他阶段,并且换行了.必须使用.trim()
The variables I'm using are from other stages and have new line.. had to use .trim()
这篇关于詹金斯管道sh添加新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文