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

Git Plugin loses commit information after upgrading to 4.8.1

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • git-plugin
    • None
    • git plugin 4.8.2

      It appears that the Git Plugin moves away from type hudson.plugins.git.Revision to type org.eclipse.jgit.lib.ObjectId and in the process, leaves some things broken.

      Reproduction
      1. Create a Dockerfile

      FROM jenkins/jenkins:2.263.4-lts-jdk11
      RUN jenkins-plugin-cli --plugins pipeline-model-definition git:4.7.2
      

      2. Build the image

      docker build -t jenkins-git-plugin-bug .
      

      3. Run the container

      docker run --rm \
          -v jenkins_home:/var/jenkins_home \
          -p 8080:8080 \
          --name jenkins-git-plugin-bug \
          jenkins-git-plugin-bug
      

      4. Create a Freestyle project that polls Git SCM
      Example config.xml

      <?xml version='1.1' encoding='UTF-8'?>
      <project>
        <actions/>
        <description></description>
        <keepDependencies>false</keepDependencies>
        <properties/>
        <scm class="hudson.plugins.git.GitSCM" plugin="git@4.8.1">
          <configVersion>2</configVersion>
          <userRemoteConfigs>
            <hudson.plugins.git.UserRemoteConfig>
              <url>https://github.com/rahulsom/jenkins-git-plugin-bug</url>
            </hudson.plugins.git.UserRemoteConfig>
          </userRemoteConfigs>
          <branches>
            <hudson.plugins.git.BranchSpec>
              <name>*/master</name>
            </hudson.plugins.git.BranchSpec>
          </branches>
          <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
          <submoduleCfg class="empty-list"/>
          <extensions/>
        </scm>
        <canRoam>true</canRoam>
        <disabled>false</disabled>
        <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
        <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
        <triggers>
          <hudson.triggers.SCMTrigger>
            <spec>* * * * * </spec>
            <ignorePostCommitHooks>false</ignorePostCommitHooks>
          </hudson.triggers.SCMTrigger>
        </triggers>
        <concurrentBuild>false</concurrentBuild>
        <builders>
          <hudson.tasks.Shell>
            <command>cat README.md</command>
            <configuredLocalRules/>
          </hudson.tasks.Shell>
        </builders>
        <publishers/>
        <buildWrappers/>
      </project>
      

      5. After the first build, update the git plugin to 4.8.1

      Expected:
      1. It should not rebuild since the repository has not changed.
      2. The older build's revision should be retained

      Actual:
      1. It assumes the commit has changed and rebuilds.
      2. You see this line in the logs

      2021-08-06 17:21:01.764+0000 [id=73]	WARNING	h.util.RobustReflectionConverter#doUnmarshal: Cannot convert type hudson.plugins.git.Revision to type org.eclipse.jgit.lib.ObjectId
      

      3. The older build shows Revision as empty after upgrading the plugin

            markewaite Mark Waite
            rahulsom Rahul Somasunderam
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: