![](/img/trans.png)
[英]How to update a Jenkins Properties Global Environment Variable from within a pipeline stage in Jenkinsfile
[英]Can I update a Jenkins Global Environment Variable from a pipeline script?
如果我在Jenkins Global Properties下定義環境變量(例如VersionNum),我可以更新管道腳本中的值嗎? 我希望用它來存儲版本信息並根據腳本執行結果進行更新。
我想要做的是寫一個管道腳本,如:
node {
stage {'Stage1') {
VersionNum = '5'
}
}
這將更新全局環境變量,以便新的值將持續存在並可供其他Jenkins作業使用。
我沒有嘗試使用全局環境變量,而是使用Pipeline Utility Steps插件讀取屬性文件:
def props = readProperties file:"${WORKSPACE}\\BuildVersion.properties"
MajVersion = props['MAJOR_VERSION'].trim()
MinVersion = props['MINOR_VERSION'].trim()
然后,如果我更改了一個值,我會將其寫回:
bat "(echo MAJOR_VERSION=${MajVersion} && echo MINOR_VERSION=${MinVersion}) \u003E \"%WORKSPACE%\\BuildVersion.properties\""
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.