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

Fetch additional refspecs during change checkout

XMLWordPrintable

      The Git plugin supports specifying additional refspecs to fetch when checking out a commit to build (added as an Additional Behaviour on the branch SCM source).

      This configuration is inherited by the Gerrit Code Review plugin, and works when building branches and tags, but is not applied when building Change commits.

      This means that any pipeline stages requiring access to other refspecs will fail, unless git fetch is called manually first. For example, SonarQube's Pull Request analysis cannot diff the Change commit against the target branch, so "new code" detection is not available.

      A 'good' build, triggered by new commits on the master branch, logs during checkout:

       [Pipeline] { (Declarative: Checkout SCM)
       [Pipeline] checkout (hide)
       using credential ********
       Cloning the remote Git repository
       Cloning with configured refspecs honoured and without tags
       Fetching without tags
       Cloning repository https://gerrit.observing.earth/a/cgi-eoss/libeopp
        > git init /home/jenkins/agent/workspace/libeopp_master # timeout=10
       Fetching upstream changes from https://gerrit.observing.earth/a/cgi-eoss/libeopp
        > git --version # timeout=10
       using GIT_ASKPASS to set credentials Jenkins Gerrit account
        > git fetch --no-tags --progress -- https://gerrit.observing.earth/a/cgi-eoss/libeopp +refs/heads/*:refs/remotes/origin/* +refs/changes/*:refs/remotes/origin/* # timeout=10
        > git config remote.origin.url https://gerrit.observing.earth/a/cgi-eoss/libeopp # timeout=10
        > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
        > git config --add remote.origin.fetch +refs/changes/*:refs/remotes/origin/* # timeout=10
        > git config remote.origin.url https://gerrit.observing.earth/a/cgi-eoss/libeopp # timeout=10
       Fetching upstream changes from https://gerrit.observing.earth/a/cgi-eoss/libeopp
       using GIT_ASKPASS to set credentials Jenkins Gerrit account
        > git fetch --no-tags --progress -- https://gerrit.observing.earth/a/cgi-eoss/libeopp +refs/heads/*:refs/remotes/origin/* +refs/changes/*:refs/remotes/origin/* # timeout=10
       Checking out Revision f001ec5077530e540fce28ba9dd5b0f134c1f01d (master)
        > git config core.sparsecheckout # timeout=10
        > git checkout -f f001ec5077530e540fce28ba9dd5b0f134c1f01d # timeout=10
       Commit message: "Use correct variable syntax in Jenkinsfile"
        > git rev-list --no-walk 6e2eec73548f36bb615b866c55448fd3ccea9fa4 # timeout=10
       [Pipeline] }
      

      And the same snippet, from an open Change in Gerrit:

       [Pipeline] { (Declarative: Checkout SCM)
       [Pipeline] checkout
       using credential ********
       Cloning the remote Git repository
       Honoring refspec on initial clone
       Checking out Revision d5328812658dee78ff25a43add7ade706100c59e (43/3943/2)
       Cloning repository https://gerrit.observing.earth/a/cgi-eoss/libeopp
        > git init /home/jenkins/agent/workspace/libeopp_43_3943_2 # timeout=10
       Fetching upstream changes from https://gerrit.observing.earth/a/cgi-eoss/libeopp
        > git --version # timeout=10
       using GIT_ASKPASS to set credentials Jenkins Gerrit account
        > git fetch --tags --force --progress -- https://gerrit.observing.earth/a/cgi-eoss/libeopp refs/changes/43/3943/2:refs/remotes/origin/43/3943/2 # timeout=10
        > git config remote.origin.url https://gerrit.observing.earth/a/cgi-eoss/libeopp # timeout=10
        > git config --add remote.origin.fetch refs/changes/43/3943/2:refs/remotes/origin/43/3943/2 # timeout=10
        > git config remote.origin.url https://gerrit.observing.earth/a/cgi-eoss/libeopp # timeout=10
       Fetching upstream changes from https://gerrit.observing.earth/a/cgi-eoss/libeopp
       using GIT_ASKPASS to set credentials Jenkins Gerrit account
        > git fetch --tags --force --progress -- https://gerrit.observing.earth/a/cgi-eoss/libeopp refs/changes/43/3943/2:refs/remotes/origin/43/3943/2 # timeout=10
        > git config core.sparsecheckout # timeout=10
        > git checkout -f d5328812658dee78ff25a43add7ade706100c59e # timeout=10
       Commit message: "Prevent multiple execution in AbstractStepOperator"
        > git rev-list --no-walk d5328812658dee78ff25a43add7ade706100c59e # timeout=10
       [Pipeline] }
      

      The key missing line is:

      > git fetch --no-tags --progress -- https://gerrit.observing.earth/a/cgi-eoss/libeopp +refs/heads/*:refs/remotes/origin/* +refs/changes/*:refs/remotes/origin/* # timeout=10
      

            lucamilanesio Luca Domenico Milanesio
            zetten Peter van Zetten
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: