![](/img/trans.png)
[英]how to add/update execute shell commands for existing jenkins jobs using groovy script
[英]How to execute shell script and update env variable using groovy?
如何編寫執行簡單的shell命令並將ev變量更新為屬性文件的groovy腳本,以便以后可以由Email-Ext使用。 這是我要使用groovy執行的shell命令:
email_recipients=`cat ${WORKSPACE}/Var/Compile/Logs/set_email_recipients.properties`
echo email_recipients=${email_recipients} > email_update.prop
創建屬性文件email_update.prop后 ,我要將其作為注入的環境變量的一部分添加到“屬性文件路徑”中。
如何將此寫為DSL腳本的一部分?
這是一個例子。 您從WORKSPACE中讀取Shell腳本(run.sh),然后選擇一個定義了環境變量的文件。
job('run-shell-script-and-update-env') {
steps {
shell(readFileFromWorkspace('${WORKSPACE}/run.sh'))
}
environmentVariables {
propertiesFile('email_update.prop')
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.