2

I recently searched for a way to merge pom.xml-s automatically with Git merge driver. Got it working locally, but now I'd like to add this solution to Jenkins -- no luck so far.

What I did:

1) I added these lines to /root/.gitconfig :

[merge "pommerge"]
    name = A custom merge driver for Maven's pom.xml
    driver = /usr/bin/mergepom.py %O %A %B

2) Created .gitattributes file in the same directory and added line:

pom.xml merge=pommerge

3) Moved mergepom.py to /usr/bin

0

First, you should use an absolute path for the driver part as per the instructions in https://github.com/ralfth/pom-merge-driver (which I guess is either the one you use or a fork thereof) - hence use /usr/bin/mergepom.py %O %A %B for the driver in your case.

Secondly, the system-wide git attributes file is probably supposed to be in $HOME/.config/git/attributes as per https://stackoverflow.com/a/28027656

Thirdly is a more philosophical point - merging files automatically using Jenkins is usually a bad idea; you might consider changing your work flow to have users do the merges and Jenkins evaluating their merges. Why is your Jenkins job performing merges (automatically merging release branches to the master branch)? Can or should a user do it instead?

0

Ah, yes, the location already was /usr/bin/mergepom.py %O %A %B, copied the original path from local env.

Looked but there is nothing under $HOME/.config. Found some hooks under /usr/share/git-core/contrib/hooks though. Will test this some day.

Well, merge conflicts are still gonna be solved manually, but when there is straight-forward merge then Jenkins would significantly reduce the time with automatic merges which would otherwise be spent going through pom.xml-s manually. The project i'm in has about 75 pom.xml-s.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.