2017-10-11 240 views
0

我目前正在嘗試將我們的主分支合併到新版本分支中,以查看該版本是否正常工作(用於測試我合併分支'master'和'infra')。我在Jenkins用管道腳本來做這件事。 但是,我在合併的每個文件中遇到合併衝突。因此,例如,如果文件foo /跳回到bar.txt在分行變更紅外線結果在我的本地回購是這樣的:通過Jenkins管道合併分支

$ git merge master 
Auto-merging foo/bar.txt 
Merge made by the 'recursive' strategy. 
... 

使用下面的腳本這是應該做的,我得到了同樣的事情以下結果:

ERROR: Branch not suitable for integration as it does not merge cleanly: Command "git merge --ff c98425e0c22d1ad35749c5eca03ca44652e22c95" returned status code 1: 
stdout: Auto-merging foo/bar.txt 
CONFLICT (add/add): Merge conflict in foo/bar.txt 
Automatic merge failed; fix conflicts and then commit the result. 

我已經嘗試了很多不同的設置,但無法讓詹金斯自動合併分支。下面是檢查出來的回購,應該把它合併,我使用片斷髮生器產生的部分:

checkout changelog: true, poll: true, scm: [$class: 'GitSCM', branches: [[name: '*/infra']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'LocalBranch', localBranch: 'infra'], [$class: 'PreBuildMerge', options: [fastForwardMode: 'FF', mergeRemote: 'origin', mergeStrategy: 'MergeCommand.Strategy', mergeTarget: 'master']]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '<id>', name: 'origin', refspec: '+refs/heads/master:refs/remotes/origin/master', url: '<url to repo>']]] 

編輯:我使用的是解決辦法,現在通過檢查出的回購,然後運行通過shell命令合併:

checkout poll: false, scm: [$class: 'GitSCM', branches: [[name: "${buildGitRevision}"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'WipeWorkspace']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '<id>', url: '<url to repo>']]] 
[...] 
sh "git merge origin/master" 
+1

完成測試合併的想法。你得到什麼類型的衝突?它是一個自動CRLF的東西,還是有'釋放'上沒有backported到'master'的實質性熱點?項目範圍內的縮進更改?我會根據問題的當前狀態寫一個答案。 – msanford

回答

0

如果將有來自合併產生的衝突,這幾乎是不可能讓你通過無人值守的過程合併。顯然,如果有衝突,分支還沒有準備好合並。此外,您不想通過無人蔘與的流程解決合併衝突:您怎麼知道要選擇哪個版本?是的,你可以強制git選擇git merge master -X theirsgit merge master -X ours或其他分支,但需要這樣做表示工作流問題。

+0

就我理解git而言,如果兩個分支中的文件都沒有改變,那麼不應該有衝突,但這是我在這裏處理的問題。在我的筆記本電腦上合併測試分支時工作得很好,而詹金斯在任何分支中更改過的每個文件都發生衝突,即使其他分支未觸及該文件。 – Julian