1

I am using Jenkins Pipeline and have a scenario where the expectation is:

In the pipeline job 'Test A' - Stage 'Checkout_A' it calls other pipeline job 'Test B' - Stage 'Checkout_B' , after that stage in Test B is completed the controller should retun back to pipeline job 'Test A' and execute Stage ('Build_A') which again calls pipeline job 'Test B' - Stage ('Build_B') then controller should retun back to pipeline job 'Test A' and execute Stage ('Transfer_A').

1)Below is the syntax i am using but its not working as above expected, appricate your inputs on how to achive this approach.

2)I want to use this approach mainly to show the pipeline different stages in upstream job itself instead of in downstream job. Is there any way or plugin available to show the stages of downstream job along with upstream job flow.

Test A
_______

Stage ('Checkout_A')
build job: 'Test B, stage: 'Checkout_B'', 
    parameters: [string(name: 'GIT_URL', value: String.valueOf(ssh://git@xxx/aaa.git )),
    string(name: 'CREDENTIALS', value: String.valueOf('xxxx123')
     ] 
    
Stage ('Build_A')
build job: 'Test B, stage: 'Build_B', 
    parameters: [string(name: 'GIT_URL', value: String.valueOf(ssh://git@xxx/aaa.git )),
    string(name: 'CREDENTIALS', value: String.valueOf('xxxx123')
     ]

Stage ('Transfer_A')
build job: 'Test B', Stage: 'Transfer_B'

Test B
________

 stage 'Checkout_B'
          git (url: '${GIT_URL}',
          credentialsId: '${CREDENTIALS}')
    build job: 'Test A, stage: Build_A'
    
Stage ('Build_B')
        bat 'call "E:\\MSBuild\\12.0\\Bin\\MSBuild.exe" Sample.sln '
    build job: 'Test A, stage: Transfer_A'
    
Stage ('Transfer_B')
       Xcopy(Source, destination)
Sri
  • 459
  • 2
  • 9
  • 20
  • What "is not working"? I assume the `stage` parameter to the `build` job, right? – StephenKing Feb 02 '18 at 06:13
  • Yes, I want to call only the stage of other pipeline job instead of executing from start to end. – Sri Feb 02 '18 at 14:07
  • Refer following ans: https://stackoverflow.com/questions/43337070/how-to-invoke-a-jenkins-pipeline-a-in-another-jenkins-pipeline-b/50166908#50166908 – Yash May 21 '18 at 11:17

1 Answers1

1

As you noticed, the build step has no parameter called stage. You simply cannot run arbitrary stages in other jobs - you can only trigger complete jobs, start to end. If you really want to separate that out (for reusability as well?), make the contents of the stage an extra job.

Regarding the visualization inline in the calling job: No, I wouldn't expect this to be possible soon. Have a look at the roadmap and you will only see the item that you actually get a link to go to the called job.

StephenKing
  • 36,187
  • 11
  • 83
  • 112
  • Thanks for your inputs. I also want to check if there is any approach to show the pipeline different stages in upstream job itself instead of in downstream job i.e., show the stages of downstream job along with upstream job flow. – Sri Feb 02 '18 at 14:09
  • Probably does not exist. – StephenKing Feb 06 '18 at 06:38