在Jenkins构建中传递动态参数 [英] Pass a dynamic parameter in Jenkins build
问题描述
我想在Jenkins中通过计划的作业传递动态参数(此构建每天凌晨3:00运行)
I want to pass a dynamic parameter in Jenkins in a scheduled job (this build runs every day at 3:00 am)
如果我在linux命令行中执行它,它将起作用:
This works if I executed it in my linux command line:
mvn package -DintegrationTag=$(date +%d-%m-%y)
或
mvn package -DintegrationTag="$(date +%d-%m-%y)"
或
mvn package -DintegrationTag="$(date +"%d-%m-%y")"
使用这3个选项,例如,这就是执行的内容(这是我要在Jenkins中执行的操作):
with these 3 options this is what is executed, for example (this is what I want to do in Jenkins):
mvn package -DintegrationTag=16-09-2013
但是这些句子中的任何一个,都不符合我的詹金斯的目标和选择(因为使用了动态参数).
but any of these sentences, do not work in my Jenkins goals and options (because the dynamic parameter).
有什么办法吗?
推荐答案
解决方案:
包含脚本的文件的内容:
Content of the file which constains the script:
echo "NOW=`date +%d-%m-%y`"> env.properties
属性文件的路径:
env.properties
在项目中,目标和选项:
In project, goals and options:
clean test package -DintegrationTag=$NOW
将环境变量注入到构建过程中= true
Inject environment variables to the build process = true
这篇关于在Jenkins构建中传递动态参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!