First, below is the script:
pipeline {
agent none
stages {
stage('Build My first job'){
steps{
build job: 'Job1', propagate: false
}
}
stage('Build Second Job'){
steps{
build job: 'Job 2', propagate: false
}
}
}
}
So, to create such a script, we can get rid of the agent. Because, for this particular job, it has no use.
Second, I found an error when I didn't put "steps" inside the stage. It looks like, this is a mandatory field now.
Later, My job started failing, because it did not execute the second job if the first job build goes to fail.
So to fix that part, I again googled and found this parameter "propagate".
If it's false, then if the build fails, it doe not allow the next build to execute.
But in my case, I need to execute the other job. So I put it as True and irrespective of the result, it executed the other job as well.
It solved my purpose. For now, I have not seen any new issue because of this, if anything will come, I will update here as well.
Till then, Happy Learning :)
#Jenkins #Groovy
No comments:
Post a Comment