简体   繁体   中英

cannot lock existing info/refs while pushing data to git central repository through jenkins

I have written below function to commit the new version to git repo. but I'm getting errors:

error: cannot lock existing info/refs fatal: git-http-push failed

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
   """

Git has two different HTTP protocols, the smart protocol and the dumb protocol. From this error message, you're using the dumb protocol, which causes a lock to be taken during the entire push process. This message means that someone else is trying to push to the repo at the same time, and you're unable to take a lock while they're doing it.

In order to fix this, you need to update your Git server to use the smart HTTP protocol, which doesn't have this problem. Most hosted Git servers have this capability, and if you've set one up yourself, you can run git http-backend --help to see the documentation about how to set it up to use the smart protocol.

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