Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there anyway with Jenkins Git plugin to set merge-strategy option to 'theirs'?

Tags:

git

merge

jenkins

I'm using Jenkins with the Git Plugin. Facts:

  • I have 2 branches develop and rc with the same ancestor.
  • develop is at commit 635d361d2005f74dd55f274bf409d43d6413d9b0
  • I'm try to merge develop it into rc
  • A change has been made to a file x.html independently in both branches that causes a conflict when merging
  • I always want develop changes to trump rc changes when conflict occurs

In the project via the git plugin, I've added an additional behavior "Merge before build" and I can set the strategy to be "recursive".

Screenshot of Jenkins Git Plugin Additional Behavior Config

This configuration generates a merge that looks like this when run:

 git checkout -f origin/rc
 git merge -s recursive 635d361d2005f74dd55f274bf409d43d6413d9b0

However, I can't seem to specify the any strategy options, so this just generates a conflict.

Specifically I'm trying to do a merge accept theirs on conflict like below:

  git checkout -f origin/rc
  git merge -s recursive  --strategy-option theirs 635d361d2005f74dd55f274bf409d43d6413d9b0

Can this be achieved with the plugin?

like image 573
Ray Avatar asked Oct 20 '22 21:10

Ray


1 Answers

I don't believe it is possible to set a merge-strategy option using the Jenkins Git plugin. What I did as a workaround was to delete the additional behavior "Merge before build". Then on the "Build" phase add a build step "Execute shell" and call the commands you were trying to execute.

like image 63
Sandio Avatar answered Oct 22 '22 22:10

Sandio