[英]Pass "git parameters" from pipeline jenkins job A to job B
I have a pipeline jenkins job A and a jenkins job B, which might or might not be a pipeline job.我有一个管道詹金斯工作 A 和一个詹金斯工作 B,这可能是也可能不是管道工作。 I have to:我必须:
For now, i'm able to trigger job B from job A, I am not able to achieve step 2. Can someone help me with this ?现在,我可以从工作 A 触发工作 B,但我无法完成第 2 步。有人可以帮我吗?
There are a few ways to do it.有几种方法可以做到。
pass variables between pipeline if using a file.如果使用文件,则在管道之间传递变量。 You mentioned you are not using pipeline so I assume you are not working with JenkinsFile您提到您没有使用管道,所以我假设您没有使用 JenkinsFile
pipeline {
// Define the desired paramaters
parameters {
string(name: 'var1', defaultValue: '')
}
// Define global variable
stage("define global var") {
steps {
env.var1 = value1
}
}
stage("test variables") {
steps {
echo "${env.var1}"
}
}
}
Write the variables to file and then read it from the disk.将变量写入文件,然后从磁盘读取。
// First set the variables
script
{
env.var1_name = "var1_value"
.....
env.varX_name = "varX1_value"
// Print the values of the variables
echo " My vars[DEV:${env.var1_name }]
}
stage('define glbal variables') {
script
{
env.var1_name = "var1_value"
.....
env.varX_name = "varX1_value"
// Print the values of the variables
echo " My vars[DEV:${env.var1_name }]
}
}
// Define Job which need teh value of the variable
stage('Job A') {
echo "NEXT JOB DEV version = ${env.var1_name }"
}
stage('Job B') {
echo "NEXT JOB DEV version = ${env.var1_name }"
}
// Define a ---groovy--- global named [var1] which can be shared between steps
var1 = 'value1'
...
pipeline {
stages {
stage('A') {
steps {
echo "${var1}"
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.