This issue is archived. You can view it, but you can't modify it. Learn more

ExportXMLWordPrintable

      in the pipeline step: checkout step, use "branches to build" with commitID
      generated by snippet and it works:
      node('master'){
      stage("1")

      { checkout changelog: true, poll: true, scm: [$class: 'GitSCM', branches: [[name: 'fc5c534716c171a03eeb31a12c1e0acff700dcbf']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'ssh://git@gitlab.is.com:7999/myRepo']]] }

      }
      but same code in the shared library does not work:
      class Git implements Serializable {
      def checkoutScm()

      { checkout changelog: true, poll: true, scm: [$class: 'GitSCM', branches: [[name: 'fc5c534716c171a03eeb31a12c1e0acff700dcbf']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'ssh://git@gitlab.is.com:7999/myRepo']]] }

      }
      }
      node('master'){
      stage("1"){
      def git = new Git()
      git.checkoutScm()

      Compared with the console, the difference in the later is:
      Fetching upstream changes from ssh://git@gitlab.is.com:7999/myRepo.git
      > /usr/bin/git fetch --tags --progress ssh://git@gitlab.is.com:7999/myRepo.git +refs/heads/:refs/remotes/origin/
      > /usr/bin/git rev-parse refs/remotes/origin/fc5c534716c171a03eeb31a12c1e0acff700dcbf^

      {commit} # timeout=10
      > /usr/bin/git rev-parse refs/remotes/origin/origin/fc5c534716c171a03eeb31a12c1e0acff700dcbf^{commit}

      # timeout=10
      > /usr/bin/git rev-parse origin/fc5c534716c171a03eeb31a12c1e0acff700dcbf^

      {commit} # timeout=10



      I assume, git rev-parse should done as
      /usr/bin/git rev-parse fc5c534716c171a03eeb31a12c1e0acff700dcbf^{commit}

      when the input is a commitId than a real branch name
      so why it tries "refs/remote/origin", " refs/remote/origin/origin", "origin" instead?

            Assignee:
            Unassigned
            Reporter:
            Wen Zhou
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Archived: