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

git plugin 3.6.4 regression with shared libraries

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • git-plugin
    • Jenkins ver. 2.73.3 running on docker (jenkins/jenkins:lts)

      Git plugin 3.6.4 has a regression when working with shared libraries when a user specifies a commit which is not the last one of the branch.

      Below the execution of the same pipeline with two version of the same plugin: the good one is 3.6.3 whilst the one which introduces the regression is 3.6.4.

      Behaviour of 3.6.3 (good one)

      Loading library xxx-jenkins-library@a39ba3363968d030eca48fc7b32e78870f580e0e
      > git rev-parse --is-inside-work-tree # timeout=10
      Setting origin to git@github.com:user/repo.git
      > git config remote.origin.url git@github.com:user/repo.git # timeout=10
      Fetching origin...
      Fetching upstream changes from origin
      > git --version # timeout=10
      using GIT_SSH to set credentials github
      > git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/*
      > git rev-parse a39ba3363968d030eca48fc7b32e78870f580e0e^\{commit} # timeout=10
      > git rev-parse --is-inside-work-tree # timeout=10
      Fetching changes from the remote Git repository
      > git config remote.origin.url git@github.com:user/repo.git # timeout=10
      Fetching without tags
      Fetching upstream changes from git@github.com:user/repo.git
      > git --version # timeout=10
      using GIT_SSH to set credentials github
      > git fetch --no-tags --progress git@github.com:user/repo.git +refs/heads/*:refs/remotes/origin/*
      Checking out Revision a39ba3363968d030eca48fc7b32e78870f580e0e (a39ba3363968d030eca48fc7b32e78870f580e0e)
      > git config core.sparsecheckout # timeout=10
      > git checkout -f a39ba3363968d030eca48fc7b32e78870f580e0e
      Commit message: "Refactor developerPipeline.groovy"
      > git rev-list a39ba3363968d030eca48fc7b32e78870f580e0e # timeout=10
      

      Behaviour of 3.6.4 (bad one)

      Loading library xxx-jenkins-library@a39ba3363968d030eca48fc7b32e78870f580e0e
      Attempting to resolve a39ba3363968d030eca48fc7b32e78870f580e0e from remote references...
      > git --version # timeout=10
      using GIT_SSH to set credentials github
      > git ls-remote -h -t git@github.com:user/repo.git # timeout=10
      Could not find a39ba3363968d030eca48fc7b32e78870f580e0e in remote references. Pulling heads to local for deep search...
      > git rev-parse --is-inside-work-tree # timeout=10
      Setting origin to git@github.com:user/repo.git
      > git config remote.origin.url git@github.com:user/repo.git # timeout=10
      Fetching origin...
      Fetching upstream changes from origin
      > git --version # timeout=10
      using GIT_SSH to set credentials github
      > git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/*
      > git rev-parse a39ba3363968d030eca48fc7b32e78870f580e0e^\{commit} # timeout=10
      > git branch -v --no-abbrev --contains a39ba3363968d030eca48fc7b32e78870f580e0e # timeout=10
      Could not find a branch containing commit a39ba3363968d030eca48fc7b32e78870f580e0e
      ERROR: No version a39ba3363968d030eca48fc7b32e78870f580e0e found for library xxx-jenkins-library
      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      WorkflowScript: Loading libraries failed
      

      Here the code of the plugin up to 3.6.4: https://github.com/jenkinsci/git-plugin/commits/git-3.6.4

      The culprit could be this commit: https://github.com/jenkinsci/git-plugin/commit/addcc0a57f2a205f7a79efda4ca15e7b6d937954

      Steps to reproduce the issue

      1) Configure the shared libraries

      2) Use them with pipeline:

      @Library('xxx-jenkins-library@sha1_of_commit_which_is_not_the_last_one') _  
      
      

      3) Execute the pipeline and you should have the above output

      WORKAROUND: use git-plugin 3.6.3

          [JENKINS-48061] git plugin 3.6.4 regression with shared libraries

          Code changed in jenkins
          User: rsandell
          Path:
          pom.xml
          src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java
          src/main/java/jenkins/plugins/git/GitSCMSourceContext.java
          src/main/java/jenkins/plugins/git/GitSCMTelescope.java
          http://jenkins-ci.org/commit/git-plugin/4a7cba88498ba5f5cdc1c4a76fac17fa0faa4f99
          Log:
          JENKINS-48061 Cleaned up comments and todos

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: rsandell Path: pom.xml src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java src/main/java/jenkins/plugins/git/GitSCMSourceContext.java src/main/java/jenkins/plugins/git/GitSCMTelescope.java http://jenkins-ci.org/commit/git-plugin/4a7cba88498ba5f5cdc1c4a76fac17fa0faa4f99 Log: JENKINS-48061 Cleaned up comments and todos

          Code changed in jenkins
          User: rsandell
          Path:
          src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java
          src/main/java/jenkins/plugins/git/GitSCMSourceContext.java
          src/main/java/jenkins/plugins/git/traits/DiscoverOtherRefsTrait.java
          http://jenkins-ci.org/commit/git-plugin/36a307a5e128e5f47d2284317a6cf1e0cb4595e5
          Log:
          JENKINS-48061 rename WantedOtherRefs to RefNameMapping

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: rsandell Path: src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java src/main/java/jenkins/plugins/git/GitSCMSourceContext.java src/main/java/jenkins/plugins/git/traits/DiscoverOtherRefsTrait.java http://jenkins-ci.org/commit/git-plugin/36a307a5e128e5f47d2284317a6cf1e0cb4595e5 Log: JENKINS-48061 rename WantedOtherRefs to RefNameMapping

          Code changed in jenkins
          User: rsandell
          Path:
          src/test/java/jenkins/plugins/git/AbstractGitSCMSourceTest.java
          http://jenkins-ci.org/commit/git-plugin/6ffc5710f70a58e42873d2f3d94d887b557685a9
          Log:
          JENKINS-48061 Added a test to verify we can retrieve a commit
          that is not on the head of a custom ref

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: rsandell Path: src/test/java/jenkins/plugins/git/AbstractGitSCMSourceTest.java http://jenkins-ci.org/commit/git-plugin/6ffc5710f70a58e42873d2f3d94d887b557685a9 Log: JENKINS-48061 Added a test to verify we can retrieve a commit that is not on the head of a custom ref

          Code changed in jenkins
          User: rsandell
          Path:
          src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java
          http://jenkins-ci.org/commit/git-plugin/191cf5562d801a0d8749c847451595271872b6a8
          Log:
          JENKINS-48061 Resolve other ref before tag name

          So we don't have to check timestamps on the tag

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: rsandell Path: src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java http://jenkins-ci.org/commit/git-plugin/191cf5562d801a0d8749c847451595271872b6a8 Log: JENKINS-48061 Resolve other ref before tag name So we don't have to check timestamps on the tag

          Code changed in jenkins
          User: Mark Waite
          Path:
          README.md
          pom.xml
          src/main/java/hudson/plugins/git/browser/AssemblaWeb.java
          src/main/java/hudson/plugins/git/browser/BitbucketWeb.java
          src/main/java/hudson/plugins/git/browser/CGit.java
          src/main/java/hudson/plugins/git/browser/FisheyeGitRepositoryBrowser.java
          src/main/java/hudson/plugins/git/browser/GitBlitRepositoryBrowser.java
          src/main/java/hudson/plugins/git/browser/GitLab.java
          src/main/java/hudson/plugins/git/browser/GitList.java
          src/main/java/hudson/plugins/git/browser/GitWeb.java
          src/main/java/hudson/plugins/git/browser/GithubWeb.java
          src/main/java/hudson/plugins/git/browser/Gitiles.java
          src/main/java/hudson/plugins/git/browser/GitoriousWeb.java
          src/main/java/hudson/plugins/git/browser/GogsGit.java
          src/main/java/hudson/plugins/git/browser/KilnGit.java
          src/main/java/hudson/plugins/git/browser/Phabricator.java
          src/main/java/hudson/plugins/git/browser/RedmineWeb.java
          src/main/java/hudson/plugins/git/browser/RhodeCode.java
          src/main/java/hudson/plugins/git/browser/Stash.java
          src/main/java/hudson/plugins/git/browser/TFS2013GitRepositoryBrowser.java
          src/main/java/hudson/plugins/git/browser/ViewGitWeb.java
          src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java
          src/main/java/jenkins/plugins/git/GitBranchSCMHead.java
          src/main/java/jenkins/plugins/git/GitBranchSCMRevision.java
          src/main/java/jenkins/plugins/git/GitRefSCMHead.java
          src/main/java/jenkins/plugins/git/GitRefSCMRevision.java
          src/main/java/jenkins/plugins/git/GitSCMBuilder.java
          src/main/java/jenkins/plugins/git/GitSCMHeadMixin.java
          src/main/java/jenkins/plugins/git/GitSCMSource.java
          src/main/java/jenkins/plugins/git/GitSCMSourceContext.java
          src/main/java/jenkins/plugins/git/GitSCMTelescope.java
          src/main/java/jenkins/plugins/git/traits/DiscoverOtherRefsTrait.java
          src/main/resources/jenkins/plugins/git/traits/DiscoverOtherRefsTrait/config.jelly
          src/main/resources/jenkins/plugins/git/traits/DiscoverOtherRefsTrait/help-nameMapping.html
          src/main/resources/jenkins/plugins/git/traits/DiscoverOtherRefsTrait/help-ref.html
          src/main/resources/jenkins/plugins/git/traits/DiscoverOtherRefsTrait/help.html
          src/main/resources/jenkins/plugins/git/traits/Messages.properties
          src/test/java/jenkins/plugins/git/AbstractGitSCMSourceTest.java
          src/test/java/jenkins/plugins/git/GitBranchSCMHeadTest.java
          src/test/java/jenkins/plugins/git/GitSCMFileSystemTest.java
          src/test/java/jenkins/plugins/git/GitSCMSourceTest.java
          src/test/java/jenkins/plugins/git/traits/DiscoverOtherRefsTraitTest.java
          src/test/resources/jenkins/plugins/git/GitBranchSCMHeadTest/testMigrationNoBuildStorm.zip
          src/test/resources/jenkins/plugins/git/GitBranchSCMHeadTest/testMigrationNoBuildStorm_repositories.zip
          http://jenkins-ci.org/commit/git-plugin/927c8295d326a755cc7443f1834d7ff9ede37ee2
          Log:
          Merge pull request #577 from rsandell/JENKINS-48061

          JENKINS-48061 Add new "Discover other refs" trait, GitBranchSCMHead and GitRefSCMHead

          Compare: https://github.com/jenkinsci/git-plugin/compare/bd8d2b9a9546...927c8295d326
          *NOTE:* This service been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/

          Functionality will be removed from GitHub.com on January 31st, 2019.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Mark Waite Path: README.md pom.xml src/main/java/hudson/plugins/git/browser/AssemblaWeb.java src/main/java/hudson/plugins/git/browser/BitbucketWeb.java src/main/java/hudson/plugins/git/browser/CGit.java src/main/java/hudson/plugins/git/browser/FisheyeGitRepositoryBrowser.java src/main/java/hudson/plugins/git/browser/GitBlitRepositoryBrowser.java src/main/java/hudson/plugins/git/browser/GitLab.java src/main/java/hudson/plugins/git/browser/GitList.java src/main/java/hudson/plugins/git/browser/GitWeb.java src/main/java/hudson/plugins/git/browser/GithubWeb.java src/main/java/hudson/plugins/git/browser/Gitiles.java src/main/java/hudson/plugins/git/browser/GitoriousWeb.java src/main/java/hudson/plugins/git/browser/GogsGit.java src/main/java/hudson/plugins/git/browser/KilnGit.java src/main/java/hudson/plugins/git/browser/Phabricator.java src/main/java/hudson/plugins/git/browser/RedmineWeb.java src/main/java/hudson/plugins/git/browser/RhodeCode.java src/main/java/hudson/plugins/git/browser/Stash.java src/main/java/hudson/plugins/git/browser/TFS2013GitRepositoryBrowser.java src/main/java/hudson/plugins/git/browser/ViewGitWeb.java src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java src/main/java/jenkins/plugins/git/GitBranchSCMHead.java src/main/java/jenkins/plugins/git/GitBranchSCMRevision.java src/main/java/jenkins/plugins/git/GitRefSCMHead.java src/main/java/jenkins/plugins/git/GitRefSCMRevision.java src/main/java/jenkins/plugins/git/GitSCMBuilder.java src/main/java/jenkins/plugins/git/GitSCMHeadMixin.java src/main/java/jenkins/plugins/git/GitSCMSource.java src/main/java/jenkins/plugins/git/GitSCMSourceContext.java src/main/java/jenkins/plugins/git/GitSCMTelescope.java src/main/java/jenkins/plugins/git/traits/DiscoverOtherRefsTrait.java src/main/resources/jenkins/plugins/git/traits/DiscoverOtherRefsTrait/config.jelly src/main/resources/jenkins/plugins/git/traits/DiscoverOtherRefsTrait/help-nameMapping.html src/main/resources/jenkins/plugins/git/traits/DiscoverOtherRefsTrait/help-ref.html src/main/resources/jenkins/plugins/git/traits/DiscoverOtherRefsTrait/help.html src/main/resources/jenkins/plugins/git/traits/Messages.properties src/test/java/jenkins/plugins/git/AbstractGitSCMSourceTest.java src/test/java/jenkins/plugins/git/GitBranchSCMHeadTest.java src/test/java/jenkins/plugins/git/GitSCMFileSystemTest.java src/test/java/jenkins/plugins/git/GitSCMSourceTest.java src/test/java/jenkins/plugins/git/traits/DiscoverOtherRefsTraitTest.java src/test/resources/jenkins/plugins/git/GitBranchSCMHeadTest/testMigrationNoBuildStorm.zip src/test/resources/jenkins/plugins/git/GitBranchSCMHeadTest/testMigrationNoBuildStorm_repositories.zip http://jenkins-ci.org/commit/git-plugin/927c8295d326a755cc7443f1834d7ff9ede37ee2 Log: Merge pull request #577 from rsandell/ JENKINS-48061 JENKINS-48061 Add new "Discover other refs" trait, GitBranchSCMHead and GitRefSCMHead Compare: https://github.com/jenkinsci/git-plugin/compare/bd8d2b9a9546...927c8295d326 * NOTE: * This service been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/ Functionality will be removed from GitHub.com on January 31st, 2019.

          Code changed in jenkins
          User: Mark Waite
          Path:
          Jenkinsfile
          http://jenkins-ci.org/commit/hello-world-plugin/96ae30edf0efe2cd54b419c80815a41a60aa8e90
          Log:
          test JENKINS-48061 no tag, no branch

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Mark Waite Path: Jenkinsfile http://jenkins-ci.org/commit/hello-world-plugin/96ae30edf0efe2cd54b419c80815a41a60aa8e90 Log: test JENKINS-48061 no tag, no branch

          Code changed in jenkins
          User: Mark Waite
          Path:
          Jenkinsfile
          http://jenkins-ci.org/commit/hello-world-plugin/cd774efec0b23bea3ee49511b7893ebb6c363d50
          Log:
          Use JENKINS-48061-no-tag-no-branch branch in test Jenkinsfile

          *NOTE:* This service been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/

          Functionality will be removed from GitHub.com on January 31st, 2019.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Mark Waite Path: Jenkinsfile http://jenkins-ci.org/commit/hello-world-plugin/cd774efec0b23bea3ee49511b7893ebb6c363d50 Log: Use JENKINS-48061 -no-tag-no-branch branch in test Jenkinsfile * NOTE: * This service been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/ Functionality will be removed from GitHub.com on January 31st, 2019.

          Mark Waite added a comment -

          Confirmed by testing a pre-release of git plugin 3.9.0 that the "modern Git" implementation is able to read Pipeline shared library references by SHA1.

          Confirmed by testing a pre-release of git plugin 3.9.0 that the "modern GitHub" implementation is unable to read Pipeline shared library references by SHA1. That was not intended to be covered in this fix, and is not covered in this fix.

          Confirmed by testing a pre-release of git plugin 3.9.0 that the "legacy Git" implementation is unable to read Pipeline shared library references by SHA1. That was not intended to be covered in this fix, and is not covered in this fix.

          Mark Waite added a comment - Confirmed by testing a pre-release of git plugin 3.9.0 that the "modern Git" implementation is able to read Pipeline shared library references by SHA1. Confirmed by testing a pre-release of git plugin 3.9.0 that the "modern GitHub" implementation is unable to read Pipeline shared library references by SHA1. That was not intended to be covered in this fix, and is not covered in this fix. Confirmed by testing a pre-release of git plugin 3.9.0 that the "legacy Git" implementation is unable to read Pipeline shared library references by SHA1. That was not intended to be covered in this fix, and is not covered in this fix.

          Mark Waite added a comment -

          Included in git plugin 3.9.0 released 12 May 2018

          Mark Waite added a comment - Included in git plugin 3.9.0 released 12 May 2018

          Diego Russo added a comment -

          All, thanks for your support and help in solving this ticket. Much appreciated.

          Diego Russo added a comment - All, thanks for your support and help in solving this ticket. Much appreciated.

            rsandell rsandell
            diegor Diego Russo
            Votes:
            8 Vote for this issue
            Watchers:
            16 Start watching this issue

              Created:
              Updated:
              Resolved: