简体   繁体   中英

Git/Gerrit Jenkins Continous Integration: How to handle rebase needs

I have a question regarding continuous integration with Jenkins for Git/Gerrit: is there any way to cancel Jenkins job execution when the Git change needs a rebase/merge due to previous change has been accepted during the waiting period?

Best Regards,

After investigation I found out a way to detect potential merge conflict. A windows based shell script looks like below:

git fetch
git merge-base HEAD origin/master > _base
set /p MERGEBASE=<_base
git merge-tree %MERGEBASE% HEAD origin/master | grep -E -A3 "changed in both">_tempDiff
cat _tempDiff
set /p VAR=<_tempDiff
if not "%VAR%"=="" (
      echo "Your change needs rebase"
      exit /b -1
)
exit /b 0

If running this script at the very first of Gerrit verification build, the build will be broken immediately when current branch modifies same file with the latest master branch, which usually user has to rebase in Gerrit after build.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM