I realize this question has been asked before here, here, and here, but none of these solutions appears to be working for my Jenkins setup and I can't figure out why.
My objective is to trigger a Jenkins build when either a new commit is made to the master
branch or when any tag (or in GitHub, a release) is added to the repo. Here's my current setup:
When I make a new commit to the master
branch, a new build is triggered. But when I add a new GitHub release, nothing happens.
Looking at my "Git Polling Log" shows the following output:
Started on Jun 20, 2017 1:25:00 AM
Polling SCM changes on master
Using strategy: Default
[poll] Last Built Revision: Revision 035c0f46422616b1862376b79c43b2562dc66f93 (origin/master)
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repositories
> git config remote.origin.url [email protected]:some-org/sample-app-frontend.git # timeout=10
Fetching upstream changes from [email protected]:some-org/sample-app-frontend.git
> git --version # timeout=10
using GIT_SSH to set credentials GitHub SSH Key
> git fetch --tags --progress [email protected]:some-org/sample-app-frontend.git +refs/heads/*:refs/remotes/origin/* +refs/tags/*:refs/remotes/origin/tags/*
Polling for changes in
Seen branch in repository origin/master
Seen branch in repository origin/tags/stage-v0.0.1
Seen branch in repository origin/tags/stage-v0.0.2
Seen branch in repository origin/tags/stage-v0.0.3
Seen branch in repository origin/tags/v0.0.4
Seen branch in repository origin/tags/v0.0.5
Seen branch in repository origin/tags/v0.0.6
Seen branch in repository origin/tags/v0.0.7
Seen 8 remote branches
> git tag -l # timeout=10
> git rev-parse refs/tags/stage-v0.0.2^{commit} # timeout=10
> git rev-parse refs/tags/v0.0.7^{commit} # timeout=10
> git rev-parse refs/tags/stage-v0.0.1^{commit} # timeout=10
> git rev-parse refs/tags/v0.0.6^{commit} # timeout=10
> git rev-parse refs/tags/v0.0.5^{commit} # timeout=10
> git rev-parse refs/tags/v0.0.4^{commit} # timeout=10
> git rev-parse refs/tags/stage-v0.0.3^{commit} # timeout=10
Done. Took 0.2 sec
No changes
Note that I'm using git polling once per minute. So it appears that git correctly detects the new branches, but somehow the git polling Jenkins is doing does not think a new branch qualifies as a "change" since it keeps reporting "No changes" at the bottom.
I have searched on this for sometime and was able to figure out the solution for triggering the jenkins job when tag is released from git hub. Here is the screenshot. Select advanced option from where git repositories are given and configure the details as below. So when release is tagged the jenkins job is triggered.
Refspec
value should be +refs/tags/*:refs/remotes/tags/*
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With