简体   繁体   中英

Build whenever a new commit happen , Jenkins + github?

We have a master branch, on which developer creates branches as feature/US-**** and then commit and push the feature branch to git.

There can be multiple feature branches for one master branch.

Now this is where I need to trigger the build. (On creation of new feature branch and on every commit/push).

I have a setup where I am polling my SCM for every H/5 * * * * and I have kept,

Branch Specifier (blank for 'any') = */feature/*
Refspec = +refs/heads/feature/*:refs/remotes/feature/*

But this still print log as :

Seen branch in repository origin/master.... 

Whereas I need to trigger build on feature branch creation and on every commit on those feature branch. Also it should not pickup those branches which has already been merged with the master?

Is this setup possible?

Yes, absolutely possible. The best setup I've personally used is a git webhooks. You can specify what events to fire events from in the webhook configuration screen: webhook example config

You'll need the jenkins github plugin: https://wiki.jenkins.io/display/JENKINS/GitHub+Plugin

Then you just point github to your jenkins instance as the webhook endpoint and configure the trigger on your job to be triggered by the hook. Example: Jenkins githook configuration

Bonus note: If you are like me and have a private jenkins instance in aws you'll have to do some fanciness with lambda and api-gateway to get github to hook in correctly. I used this code to do it: https://github.com/pristineio/lambda-webhook

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