I'm in the process of setting up Git/Jenkins for a new project at work. It's the first time anyone at work has used either of these tools (currently we're using SVN and a custom build system). I've managed to get a system working; a developer does a commit, pushes to an origin/develop branch which triggers a Jenkins job using a post-receive trigger then Jenkins runs a number of testing jobs. If the tests pass, Jenkins does a push to origin/master.
This is working fine, but the problem is what happens when a build fails. A requirement is that the origin/master and origin/develop branches should be the same. So when a build fails, origin/develop should be reset to the same revision as origin/master. Again, I can do this using the following commands (this is part of another Jenkins job which is triggered on a failed build):
git checkout develop
git reset --hard origin/master
git push -f
This resets the branch correctly and all is well. Except for one thing. Git sees this new push to the develop branch and triggers a new build.
So my questions is, how do I reset the develop branch to the master branch and tell Git to not trigger a build? The end goal is to reset the branch, I'm open on the mechanics. I can think of a couple of ways: add some information that the post-receive hook can pick up, however my research seems to suggest you can't pass parameters to hooks. Since there's no commit being done I can't use info from the last commit. Am I better off putting something in the triggered Jenkins build to abort if it somehow detects a rollback? Any ideas would be welcome.
One other thought. Is there a need to rollback develop at all? What happens if another push is made to origin/develop? Will it overwrite what's already there, add to it or just fail? Developers will be pulling from origin/master before making changes. The whole branching thing in Git confuses me a bit.