我写了下面的函数来将新版本提交给git repo。但是我收到了错误:
错误:无法锁定现有信息/参考号 致命:git-http-push失败
def commitBuildNumberChanges(currentProjectVersion,newVersion,projectDirectory){
echo "Preparing updated files for commit..."
def POM="pom.xml"
def BUILD_NUMBER_CHANGES_COMMIT_MESSAGE
def branch = env.BRANCH_NAME
sh """
git checkout ${branch}
git config --global user.name "jenkinsSCM"
git config --global user.email "xxx.xxxx.xxx@xxx.xxx"
git branch
git status
git fetch
# add the now updated pom files
echo "Adding pom files..."
cd ${projectDirectory}
for POM in `find . -name pom.xml` ; do
git add ${POM}
echo " - ${POM}"
done
echo "Committing changes..."
git commit -m "Auto commit from CI - incremented build number from ${currentProjectVersion} to ${newVersion}. "
git status
git remote show origin
echo "Pushing changes to origin..."
git push origin ${branch}
git status
"""
答案 0 :(得分:0)
Git有两种不同的HTTP协议,即智能协议和哑协议。从此错误消息中,您正在使用哑协议,这会导致在整个推送过程中执行锁定。此消息表示其他人正在尝试同时推送到回购,并且您在执行此操作时无法锁定。
为了解决这个问题,您需要更新您的Git服务器以使用智能HTTP协议,该协议没有此问题。大多数托管的Git服务器都具有此功能,如果您自己设置了一个,则可以运行git http-backend --help
以查看有关如何将其设置为使用智能协议的文档。