简体   繁体   中英

Jenkins trigger another job for specific branch

I'd have a pipeline with some jobs until the deploy like that:

(unit test) -> (integration test) -> (package) -> (deploy)

but I'd like to run the jobs (unit test) and (integration test) in all branches, and run jobs (package) and (deploy) only on changes on branch master.

How can I do it? Are there a conditional trigger plugin?

If you have a fixed number of branches, it's easiest to have separate Jenkins jobs for each branch. If you use a single job to build multiple branches, it will be hard to tell which branch a particular build ran on when you look at the build history.

You can create the jobs for different branches by copying from an existing job via the UI, or you could look at the Job DSL plugin if you want to automate job creation and make it easy to create jobs for new branches.

UPDATE: 2018

The flexible publish plugin ( github ) can do this now.

You can specify run conditions (eg based on the a regex match of GIT_BRANCH ) and a flexible set of actions to take when conditions match.

I am using this to trigger downstream deployment jobs only for the develop branch of one of our repositories.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM