如何在 Jenkins Pipeline 中使用注入环境变量(属性文件路径)
How to use inject environment variables (Properties File Path) in Jenkins Pipeline
想在 Jenkins 中使用以下功能(如图 link 所示)作为代码,但我没有这样做,请帮助我将图像中的功能复制到 groovy 脚本
stage ('Build Instance') {
sh '''
bash ./build.sh -Ddisable-rpm=false
'''
env "/fl/tar/ver.prop"
}
Jenkins GUI usage of Env Inject
有一个简单的解决方法:
script {
def props = readProperties file: '/fl/tar/ver.prop' //readProperties is a step in Pipeline Utility Steps plugin
env.WEATHER = props.WEATHER //assuming the key name is WEATHER in properties file
}
想在 Jenkins 中使用以下功能(如图 link 所示)作为代码,但我没有这样做,请帮助我将图像中的功能复制到 groovy 脚本
stage ('Build Instance') {
sh '''
bash ./build.sh -Ddisable-rpm=false
'''
env "/fl/tar/ver.prop"
}
Jenkins GUI usage of Env Inject
有一个简单的解决方法:
script {
def props = readProperties file: '/fl/tar/ver.prop' //readProperties is a step in Pipeline Utility Steps plugin
env.WEATHER = props.WEATHER //assuming the key name is WEATHER in properties file
}