Reputation: 11
Can i revert back the commit in git if the build fails in jenkins or bamboo? Can we write checks or script to do the revert in GIT, pre commit hooks or do we have any plugin available in jenkins or Bamboo for this?
Upvotes: 1
Views: 3562
Reputation: 10859
With subversion or any other centralized version control system, this would make more sense, since every commit goes to the central server and hopefully to Jenkins. So if one of these commits failed, you could revert it. However, with Git, you'd probably push multiple commits at once. Would you want to revert all of them even if probably just one of them is bad?
Expanding on Haralan's comment, branching is the way to go. I am using GitHub and the pull request plugin is a great tool for that use case. Push code to your branch as frequently as you want. If it's a long running branch, probably merge in changes from master from time to time. Once you're satisfied, create a pull request — Jenkins will display the result right on the pull request's GitHub page where you can also merge it into master.
So no need for reverts, only merge good stuff.
Upvotes: 2