I have a pipeline job and two Maven jobs as shown below.
node {
def res
stage('Build') {
node('rhel6') {
res = build job: "Build", parameters:
[
string(name: 'jobname', value:'master'),
string(name: 'val1', value: 'MyValue')
]
}
}
stage('Deploy') {
node('rhel6') {
build job: 'Deploy', parameters:
[
string(name: 'resName', value: "$res.buildVariables.filename")
string(name: 'firstVal', value: 'First_Argument')
]
}
}
}
As you can see from my pipeline definition, I have a pipeline job and two jobs run under pipeline stages. The 'Build' job takes two string parameters and builds.
The Deploy job takes one input from Build job and builds.
1) Is this the right way of passing parameters between stages in jenkins pipeline? I'm using an approach similar to this.
2) How are the parameters mapped in the pipeline job to the parameters in the actual job? For Example: In pipeline job above, In 'Build' stage, I have jobname and val1 as parameters. How are these params mapped to actual params in the Build job?
3) How do i automate the generation of this pipeline job from job dsl scripts? I mean, how to generate the above pipeline itself in Jenkins?