For a project A I want to trigger it's build when B is built successfully.I can achieve this through the Jenkins console by selecting the option from Build trigger.
Now I wanna achieve this by writing corresponding steps in Jenkins file of project A.
What steps can be used I tried triggers{ upstream('B',hudson.model.Result.SUCCESS) }
From https://www.jenkins.io/doc/book/pipeline/syntax/#triggers :
The upstream trigger "accepts a comma-separated string of jobs and a threshold. When any job in the string finishes with the minimum threshold, the Pipeline will be re-triggered. For example:
triggers { upstream(upstreamProjects: 'job1,job2', threshold: hudson.model.Result.SUCCESS) }"To trigger a build of Project A after Project B has been built successfully, Project A's JenkinsFile might look like:
where
project_b_job_pathis equal to the absolute or relative path of the job, for example:projects/project_b/master../project_b/mastertest_branch