[英]Can we define a variable inside a Jenkins parameterized build
My scenario is, I have parameterized build and inside the build section, I have executed shell where I define a variable and then echo to print it. 我的场景是,我已经对build进行了参数化,并且在build部分中,我执行了shell,在其中定义了一个变量,然后回显以将其打印出来。 But it doesn't print anything in the console output.
但是它不会在控制台输出中显示任何内容。
I hope I have made myself clear. 我希望我已经说清楚了。 Could anyone please answer my question?
有人可以回答我的问题吗?
current_folder=`date +%Y%m%d-%H%M%S`
echo $current_folder
I'm using Jenkins ver. 我正在使用Jenkins ver。 2.32.3 and a simple freestyle job, running on mac OS, using an execute shell build step of:
2.32.3和一个简单的自由式作业,该作业在mac OS上运行,使用以下执行外壳构建步骤:
current_folder=`date +%Y%m%d-%H%M%S`
echo $current_folder
Gives output of: 提供以下内容的输出:
$ /bin/sh -xe /var/folders/kh/4fl0eeldofefmmsfd/T/hudson89388543547899686.sh
++ date +%Y%m%d-%H%M%S
+ current_folder=20180613-081712
+ echo 20180613-081712
20180613-081712
Finished: SUCCESS
In a similar fashion, setting the shell: 以类似的方式,设置外壳:
#!/bin/bash
current_folder=`date +%Y%m%d-%H%M%S`
echo $current_folder
Gives: 给出:
$ /bin/bash /var/folders/kh/by0kd93dfew5fgjhy000h6/T/hudson62702345565786787.sh
20180613-081655
Finished: SUCCESS
The same applies to a parameter that is defined as part of the Jenkins job, underneath the 这同样适用于在詹金斯(Jenkins)工作中定义的参数,位于
This project is parameterized
checkbox once set. This project is parameterized
复选框。 For example, if you have a string parameter called userName
with a default value of User1
, then you can print it's value in an Execute Shell
build step using: 例如,如果您有一个名为
userName
的字符串参数,其默认值为User1
,则可以在Execute Shell
构建步骤中使用以下命令打印其值:
echo $userName
echo ${userName}
echo "In a string ${userName}"
Giving: 给予:
User1
User1
In a string User1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.