sherinsusan
sherinsusan

Reputation: 1

Can I trigger a build on the master branch of repo A whenever there is a merge to master happens on repo B through Jenkinsfile?

I have 5 java microservices where whenever in any of those 5 services a developer merges the code to master, it has to trigger an api-testing microservice that will initiate testing for it. For now I am manually triggering the jenkins "build with parameters" option to trigger the api-testing but would prefer to automate the "build trigger" in api-testing microservice whenever there is a merge to master in other repos. Could someone give any suggestions or samples on this?

tried to add a few lines in the jenkinsfile step but that didnt help.

Upvotes: 0

Views: 94

Answers (1)

M B
M B

Reputation: 3430

You could create 5 separate job that have incoming webhooks to each of those 5 repositories. Each of these 5 jobs would have your api-testing job as their downstream job. Whenever there is a merge to master the individual job would get triggered, and it's only function would be to finish and start the downstream job. You could either create all 5 of the jobs as freestyle pipelines that do no processing and only exist to trigger the downstream job, or have a declarative pipeline with the pipeline code in one repo. This repo can then be referenced by all 5 pipelines so that you don't have to repeat yourself.

Upvotes: 0

Related Questions