Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using git webhook, jenkins run build when code pushed to specific Branch #178

Open
guruvamsichintala opened this issue Dec 2, 2016 · 10 comments

Comments

@guruvamsichintala
Copy link

I have scenario where I have two branches B1 and B2. I have configured two jobs in Jenkins which builds those branches when something is pushed to github. Right now even though some one pushed code into B1, jenkins runs both the jobs as webhook triggered jenkins with code push. Is there a way I can run jenkins job using git webhook where B1 job must run only when git receives push for B1

@RishabhTayal
Copy link

I am having the same issue. Any solutions?

@guruvamsichintala
Copy link
Author

On github, instead of jenkins-github plugin , used jenkins-git plugin with url " http://yourserver/jenkins/git/notifyCommit?url= ". Then in the jenkins jobs changed the build trigger to Poll SCM , but do not specify a schedule instead of Build when a change is pushed to GitHub.

Follow the link:
http://stackoverflow.com/questions/5784329/how-can-i-make-jenkins-ci-with-git-trigger-on-pushes-to-master

@RishabhTayal
Copy link

@guruvamsichintala how does it trigger build only on a specific branch?

@guruvamsichintala
Copy link
Author

As you configured the "notifycommit url" and jenkins jobs to poll, Git notifies jenkins when code is pushed. Then it checks all the jobs with poll and checks if any job is configured with changed branch and triggers it.

@RishabhTayal
Copy link

@guruvamsichintala we are not using this plugin on Github. It's on stash server(aka bit bucket server).

@thrownullpointer
Copy link

What do your jenkins jobs configurations look like? I have the same setup (we actually have 1 job per branch). If someone modifies master (by a commit) it doesn't trigger the jobs using a different branch.

@guruvamsichintala
Copy link
Author

earlier we configured "build when pushed to git repository" in build triggers which didn't work. All the jobs used to trigger build even though a code is pushed to single branch.
Now we changed the build trigger to "Poll SCM" without any schedule and change the plugin on github that notifies jenkins, which works.
How are your jenkins jobs configured? Are you using jenkinsfile and paced it on github to notify ?

@raptordzuricsko
Copy link

Ran into issues with this and it seemed like the only way around it was to use a fork workflow instead of a clone workflow. hoping to revisit this.

@alexBraidwood
Copy link
Contributor

alexBraidwood commented Aug 29, 2017

@raptordzuricsko Does #172 fix your problem? I'm currently testing it for a merge.

@raptordzuricsko
Copy link

I believe it does. you are a hero alexBraidwood !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants