[英]Pass variable from jenkins pipeline job to other pipeline job
Pass variable from jenkins pipeline job to other pipeline job:将变量从 jenkins 管道作业传递到其他管道作业:
I have a following job:我有以下工作:
stage ('Upgrade') {
steps {
build job: 'Upgrade',
parameters: [string(name: 'sourcePath', value: '%publishPath%"\"%folderBuild%')]
}
}
Call to other job打电话给其他工作
pipeline {
agent { label 'master' }
stages {
stage('Upgrade') {
steps {
sh "ansible-playbook -i inventory playbook.yml --extra-vars "name=build_path value=%sourcePath%"
}
}
}
}
Question: what's wrong?问:怎么了?
stage ('Upgrade') {阶段(“升级”){
steps {脚步 {
build job: 'Upgrade', parameters: [string(name: 'sourcePath', value: env.buildPath)]构建作业:'升级',参数:[字符串(名称:'sourcePath',值:env.buildPath)]
} }
} }
In following this job you have to define String parameter called SourcePath在执行此作业时,您必须定义名为 SourcePath 的字符串参数
stages {阶段{
stage('Upgrade') {阶段(“升级”){
steps { sh label: '', script: 'ansible-playbook -i inventory upgrade.yml -e "buildPath=${sourcePath}"'步骤{ sh label:'',脚本:'ansible-playbook -i inventory upgrade.yml -e "buildPath=${sourcePath}"'
} }
} }
} }
In Ansible create env var as following:在 Ansible 创建环境变量如下:
vars:变量:
build_path: "{{ buildPath }}" // buildPath from Jenkins job build_path: "{{ buildPath }}" // 来自 Jenkins 作业的 buildPath
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.