I have two declarative pipelines in Jenkins. I would like to trigger pipelineB within parameters from the stage that is running inside pipeline A and check the build/stage results of pipelineB to decide whether if pipelineA should be continue or aborted. If pipelineB build/stage results is success then pipelineA should continue with Stage C, unless it should be aborted.
stage('A'){
steps{
script{
//Do something
}
stage ('B'){
steps {
script {
// Trigger another pipeline and check result of this
build job: 'pipelineB', parameters: [
string(name: 'param1', value: "value1")
]
}
}
}
stage('C'){
steps{
script{
//Do something
}
Get the downstream job build result and assign to upstream job build result.
script {
// Trigger another pipeline and check result of this
ret = build(job: 'pipelineB',
parameters: [
string(name: 'param1', value: "value1")
],
propagate: true,
wait: true)
echo ret.result
currentBuild.result = ret.result
}
Read here for detail