Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-41794

Groovy pipeline: Git command didn't checkout the last commit

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Trivial Trivial

      The problem: once, when I've run in Groovy pipeline [multibranch mode] git command to fetch the latest codebase to the slave workspace. The command:

      git([url: 'https://github.com/myorg/myrepo.git', branch: "${env.BRANCH_NAME}", credentialsId: "${env.CREDENTIALS_ID}"])
      

      Command output:

       > git init /home/jenkins/workspace/myjob_master-U53VEN73XGVKUQMHQMUNYUI3M2EMMZ6IAKD7LIC32FLG7MMBHHIQ # timeout=10
       > git --version # timeout=10
       > git fetch --tags --progress https://github.com/myorg/myrepot.git +refs/heads/*:refs/remotes/origin/*
       > git config remote.origin.url https://github.com/myorg/myrepo.git # timeout=10
       > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
       > git config remote.origin.url https://github.com/myorg/myrepo.git # timeout=10 
       > git fetch --tags --progress https://github.com/myorg/myrepo.git +refs/heads/*:refs/remotes/origin/*
       > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
       > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
       > git config core.sparsecheckout # timeout=10
       > git checkout -f 950c0037ee3d2b2803380baa5c0d7812a47dd6b9
       > git branch -a -v --no-abbrev # timeout=10
       > git checkout -b master 950c0037ee3d2b2803380baa5c0d7812a47dd6b9
      

      Although it has to checkout the latest version - it didn't. And there was no error in the build workflow. So, I've got the obsolete repo state, built to Docker image and finally got some sort of troubleshooting because the problem was not so obvious. When I connected to the troubled slave and check the git - the commit wasn't there. I just made a git pull into the workspace, rebuilt the Docker image and got the latest application version.
      I tried to reproduce the possible bug, but I couldn't. I rebuilt the pipeline at the clean workspace, later trying to roll out the commit with changes. And commit came! So, I still confused what kind of bug it was.

      So, please, help me to understand where is the problem might be. If you have to know additional details - please, write, what kind of.

      Thanks in advance.

            Unassigned Unassigned
            cazorla19 Mikhail Chinkov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: