stash-jenkins-postreceive-webhook
stash-jenkins-postreceive-webhook copied to clipboard
Using git webhook, jenkins run build when code pushed to specific Branch
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
I am having the same issue. Any solutions?
On github, instead of jenkins-github plugin , used jenkins-git plugin with url " http://yourserver/jenkins/git/notifyCommit?url=<URL of the Git repository> ". 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
@Guruvamsichintala how does it trigger build only on a specific branch?
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.
@guruvamsichintala we are not using this plugin on Github. It's on stash server(aka bit bucket server).
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.
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 ?
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.
@raptordzuricsko Does #172 fix your problem? I'm currently testing it for a merge.
I believe it does. you are a hero alexBraidwood !