Jenkins trigger downstream job

origin_job 触发 second_job

origin_job 如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//declarative pipeline
pipeline {
agent any

stages {
stage('Stage One'){
steps{
sh "echo *** This is Stage One ***"
}
}

stage('Stage Two'){
steps{
sh "echo ${env.BUILD_NUMBER}"
sh "echo ${env.NODE_NAME} , ${env.JOB_NAME}"
}
}

stage("Invoke second job without parameters"){
steps{
build job: 'second_job'
sleep 30
}
}

stage("Invoke second job with parameters"){
steps{
build job: 'second_job',
parameters:[
string(name:'Para1',value:String.valueOf(JOB_NAME)),
string(name:'Para2',value:String.valueOf(BUILD_NUMBER))
]
}
}

}
}

second_job

点击““参数化构建””手动添加 两个参数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
pipeline {
agent any

stages {
stage('Stage One'){
steps{
sh "echo *** This is ${env.JOB_NAME} ,and We are stage one ***"
}
}

stage('Echo origin_job para'){
steps{
sh "echo ${env.Para1}"
sh "echo ${env.Para2}"
}
}
}
}
Donate
  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
  • Copyrights © 2019-2024 John Doe
  • Visitors: | Views:

请我喝杯咖啡吧~