Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make Jenkins see a Git merge commit as a change?

Tags:

git

merge

jenkins

Users A and B each make modifications (on different feature branches) to a particular repo.

User A merges changes into staging branch. Jenkins builds the staging branch, and succeeds.

User C (release manager for User B team) merges User B’s changes into staging branch. However, something in the merge goes wrong and isn’t noticed, such as a conflict that wasn’t resolved properly.

Jenkins builds the staging branch, and fails because of the bad merge.

Users A and B are notified of the build failure, because their code was part of the merge, even though their changes were not at fault. User C never gets a failure notice, even though his bad merge was what broke the build.

Is there a way to:

  1. Cause Jenkins to treat merge commits as changes? (There is the very real possibility that code will actually be modified during a merge!)
  2. Notify User C (as the merge committer) along with users A and B?

We are using the Git and Email-ext plugins for Jenkins.

Edit, several months later: Still having issues with this — even in a scenario where the person who did the merge did not introduce breaking changes, it would still be nice for them to be notified that the build succeeded (or failed).

like image 502
GalacticCowboy Avatar asked Nov 20 '13 16:11

GalacticCowboy


People also ask

How do I see changes in a merge commit?

It shows all the changes made to the merged branch as a result of the merge. Show activity on this post. git show -c c0f501 will display a combined diff from commit c0f501 to both of its parents, as printed by git diff during a merge. This gives a better overview than git show -m .

Does merge count as a commit?

The merge commit is considered a single commit (I'd expect 13 commits now, unless you're not counting merge commits or one of the 5 and 7 is actually the same commit), but it brings all of the histories it merges together.

Does squash and merge create a new commit?

Squash merging is a merge option that allows you to condense the Git history of topic branches when you complete a pull request. Instead of each commit on the topic branch being added to the history of the default branch, a squash merge adds all the file changes to a single new commit on the default branch.

How do you checkout a commit before a merge?

You can do a git reset --hard [commit hash] to go back to the commit before the merge, and it's like traveling back in time. However, you'll also undo any changes that were added after the commit you specify in the reset command, if you have any.


1 Answers

You can try to force always no fast-forward merges (--no-ff option) and all merges will produce even a merge-commit (not only when there are conflicts).

It also produce a more readable and clear git log.

BTW check if you have the last version of the Jenkins Git plugin (they had issues in the past).

like image 76
Dario Avatar answered Oct 12 '22 01:10

Dario