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

git-client changelog timestamp is wrong

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Critical
    • Resolution: Fixed
    • Component/s: git-client-plugin
    • Labels:
      None
    • Environment:
      Java 1.8
      Git 2.4.5
      Git Client Plugin: 1.18.0
      Git Plugin: 2.4.0
    • Similar Issues:

      Description

      The RAW command listed here: https://github.com/jenkinsci/git-client-plugin/blob/b6fe319297b9ef5ceb29b260aa37c6cf994b414a/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java#L734

      Is using the old formatting of "%ai" and "%ci" for retrieving the Author and Committer timestamps. In Git 2.0 and above, the lowercase "i" refers to "ISO-8601-like" while a newly added uppercase "I" returns "ISO-8601-strict": http://git-scm.com/docs/pretty-formats

      I'm not sure why, but when upgrading 1.14.1 of git-client to 1.18.0, this started breaking for us. We're now getting -1 for all timestamps. I think it's from this change: https://github.com/jenkinsci/git-client-plugin/commit/de49c9bf21f560ac3851c4f7ea3a3597a114ac8e#diff-4a13310f7c84a9d6e133def48c0aed5a

      Here is an example:

      $ git --version
      git version 2.4.5
      $ git whatchanged --no-abbrev -M --format="commit %H%ntree %T%nparent %P%nauthor %aN <%aE> %ai%ncommitter %cN <%cE> %ci%n%n%w(76,4,4)%s%n%n%b"
      commit 688eda2a898ba11e6173f75d8fbd19cc172abb6a
      tree 12a4ac27c0f153644daf083c7e1601644ac7ab17
      parent d1da71b1f09f675af86b7fe1937d9c5f2740b182
      author Mark Waite <mark.earl.waite@gmail.com> 2015-08-20 08:48:02 -0600
      committer Mark Waite <mark.earl.waite@gmail.com> 2015-08-20 08:48:02 -0600
      
          Update findbugs maven plugin to 3.0.2
      $ git whatchanged --no-abbrev -M --format="commit %H%ntree %T%nparent %P%nauthor %aN <%aE> %aI%ncommitter %cN <%cE> %cI%n%n%w(76,4,4)%s%n%n%b"
      commit 688eda2a898ba11e6173f75d8fbd19cc172abb6a
      tree 12a4ac27c0f153644daf083c7e1601644ac7ab17
      parent d1da71b1f09f675af86b7fe1937d9c5f2740b182
      author Mark Waite <mark.earl.waite@gmail.com> 2015-08-20T08:48:02-06:00
      committer Mark Waite <mark.earl.waite@gmail.com> 2015-08-20T08:48:02-06:00
      
          Update findbugs maven plugin to 3.0.2
      

      With the lower-case "i" we're not getting ISO8601 and it's not parsing in: https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/hudson/plugins/git/GitChangeSet.java#L213-L216

        Attachments

          Activity

          Hide
          markewaite Mark Waite added a comment -

          Can you describe where you're seeing the time stamp as "-1"? Is it in the change logs, the summary of changes with each build, through an API call, or some other location?

          Can you provide a series of steps that will allow others to see the same failure you're seeing?

          Does your time zone or locale affect the behavior?

          The plugin needs to support git versions older than git 2. Many users are running older platforms (CentOS 6 - git 1.7.1, CentOS 7 - git 1.8.3.1, Debian 6 - git 1.7.2.5, Debian 7 - git 1.7.10.4, Ubuntu 14.04 - git 1.9.1, Windows - msysgit 1.9.5). I'm willing to consider inserting git version specific code, but it is more painful to maintain, more difficult to test, and more likely to break.

          Show
          markewaite Mark Waite added a comment - Can you describe where you're seeing the time stamp as "-1"? Is it in the change logs, the summary of changes with each build, through an API call, or some other location? Can you provide a series of steps that will allow others to see the same failure you're seeing? Does your time zone or locale affect the behavior? The plugin needs to support git versions older than git 2. Many users are running older platforms (CentOS 6 - git 1.7.1, CentOS 7 - git 1.8.3.1, Debian 6 - git 1.7.2.5, Debian 7 - git 1.7.10.4, Ubuntu 14.04 - git 1.9.1, Windows - msysgit 1.9.5). I'm willing to consider inserting git version specific code, but it is more painful to maintain, more difficult to test, and more likely to break.
          Hide
          markewaite Mark Waite added a comment -

          When that -1 is reported, do you also get a stack trace in the Jenkins log file on the server? An as yet unreleased change to the date parsing (for Java 6 compatibility) might help with this case, if a stack trace is being placed into the log file when the request is made.

          If you're not running Java 6, then that is not likely the problem.

          Show
          markewaite Mark Waite added a comment - When that -1 is reported, do you also get a stack trace in the Jenkins log file on the server? An as yet unreleased change to the date parsing (for Java 6 compatibility) might help with this case, if a stack trace is being placed into the log file when the request is made. If you're not running Java 6, then that is not likely the problem.
          Hide
          cynthiax Cynthia Li added a comment -

          We are seeing them in all changelog through api calls. The timestamp in summary of changes with each build is correct.

          It's internal API call so I am not sure how to let you replicate this. But the problem believe to be https://github.com/jenkinsci/git-client-plugin/blob/de49c9bf21f560ac3851c4f7ea3a3597a114ac8e/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java#L704 not using %aI

          Show
          cynthiax Cynthia Li added a comment - We are seeing them in all changelog through api calls. The timestamp in summary of changes with each build is correct. It's internal API call so I am not sure how to let you replicate this. But the problem believe to be https://github.com/jenkinsci/git-client-plugin/blob/de49c9bf21f560ac3851c4f7ea3a3597a114ac8e/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java#L704 not using %aI
          Hide
          markewaite Mark Waite added a comment -

          Unfortunately, we can't abandon support for git versions prior to git 2, so we can't switch to the argument form you listed.

          Can you provide a small test program which shows the problem, possibly using the Cloudbees Jenkins server so that you don't need to host a public server?

          Show
          markewaite Mark Waite added a comment - Unfortunately, we can't abandon support for git versions prior to git 2, so we can't switch to the argument form you listed. Can you provide a small test program which shows the problem, possibly using the Cloudbees Jenkins server so that you don't need to host a public server?
          Hide
          vkopchenin Slava Kopchenin added a comment - - edited

          I have the same problem for all builds timestamp.png.

          -bash-4.2# git --version
          git version 2.4.0

          Jenkins ver. 1.609.3

          GIT client plugin
          Shared library plugin for other Git related Jenkins plugins.
          1.19.0

          Git plugin
          This plugin integrates Git with Jenkins.
          2.4.0

          Show
          vkopchenin Slava Kopchenin added a comment - - edited I have the same problem for all builds timestamp.png . -bash-4.2# git --version git version 2.4.0 Jenkins ver. 1.609.3 GIT client plugin Shared library plugin for other Git related Jenkins plugins. 1.19.0 Git plugin This plugin integrates Git with Jenkins. 2.4.0
          Hide
          markewaite Mark Waite added a comment - - edited

          Slava Kopchenin thanks for the picture. It showed that the API call is a public API that is easily accessible. That makes it easier to write a test for this bug.

          For example, I see a problem timestamp in the json response when I request http://localhost:8085/view/git-client/job/git-client-multi-master/242/api/json but not when I request http://localhost:8085/view/git-client/job/git-client-multi-master/244/api/json. In my use case, it doesn't seem to be an "every build" occurrence, but it happens on at least some of my cases.

          Is your Jenkins server running with Java 6, or with a later version of Java?

          Show
          markewaite Mark Waite added a comment - - edited Slava Kopchenin thanks for the picture. It showed that the API call is a public API that is easily accessible. That makes it easier to write a test for this bug. For example, I see a problem timestamp in the json response when I request http://localhost:8085/view/git-client/job/git-client-multi-master/242/api/json but not when I request http://localhost:8085/view/git-client/job/git-client-multi-master/244/api/json . In my use case, it doesn't seem to be an "every build" occurrence, but it happens on at least some of my cases. Is your Jenkins server running with Java 6, or with a later version of Java?
          Hide
          vkopchenin Slava Kopchenin added a comment - - edited

          "for all builds" I mean in my case...

          I logged the hudson.plugins.git.GitChangeSet#parseCommit and the jenkins.log has the following output:

          commit 302548f75c3eb6fa1db83634e4061d0ded416e5a
          tree e1bd430d3f45b7aae54a3061b7895ee1858ec1f8
          parent c74f084d8f9bc9e52f0b3fe9175ad27c39947a73
          author Viacheslav Kopchenin <vkopchenin@odin.com> 2015-10-06 19:29:47 +0300
          committer Viacheslav Kopchenin <vkopchenin@odin.com> 2015-10-06 19:29:47 +0300
          
              pom.xml
          
          :100644 100644 bb32d78c69a7bf79849217bc02b1ba2c870a5a66 343a844ad90466d8e829896c1827ca7511d0d1ef M	modules/platform/pom.xml
          

          But, when I changed(ai->aI, ci->cI):

          -            public static final String RAW = "commit %H%ntree %T%nparent %P%nauthor %aN <%aE> %ai%ncommitter %cN <%cE> %ci%n%n%w(76,4,4)%s%n%n%b";
          +            public static final String RAW = "commit %H%ntree %T%nparent %P%nauthor %aN <%aE> %aI%ncommitter %cN <%cE> %cI%n%n%w(76,4,4)%s%n%n%b";
          

          The output is:

          commit 841fd27f1a0ef11a1696e3a5cb6eced316761ee3
          tree 369d49618e2752d809ee8807149c402485b8e15b
          parent b5ad39f1d9c338cb76b2851d8b2ebcef7d59484e
          author Viacheslav Kopchenin <vkopchenin@odin.com> 2015-10-06T20:09:18+03:00
          committer Viacheslav Kopchenin <vkopchenin@odin.com> 2015-10-06T20:09:18+03:00
          
              pom.xml
          
          :100644 100644 5868c1b334fdea0d25b21705604e9e1d6f3243b8 56f50739924afe9d151a3c89aa7ace332e55b044 M	modules/platform/pom.xml
          
          Show
          vkopchenin Slava Kopchenin added a comment - - edited "for all builds" I mean in my case... I logged the hudson.plugins.git.GitChangeSet#parseCommit and the jenkins.log has the following output: commit 302548f75c3eb6fa1db83634e4061d0ded416e5a tree e1bd430d3f45b7aae54a3061b7895ee1858ec1f8 parent c74f084d8f9bc9e52f0b3fe9175ad27c39947a73 author Viacheslav Kopchenin <vkopchenin@odin.com> 2015-10-06 19:29:47 +0300 committer Viacheslav Kopchenin <vkopchenin@odin.com> 2015-10-06 19:29:47 +0300 pom.xml :100644 100644 bb32d78c69a7bf79849217bc02b1ba2c870a5a66 343a844ad90466d8e829896c1827ca7511d0d1ef M modules/platform/pom.xml But , when I changed( ai->aI, ci->cI ): - public static final String RAW = "commit %H%ntree %T%nparent %P%nauthor %aN <%aE> %ai%ncommitter %cN <%cE> %ci%n%n%w(76,4,4)%s%n%n%b" ; + public static final String RAW = "commit %H%ntree %T%nparent %P%nauthor %aN <%aE> %aI%ncommitter %cN <%cE> %cI%n%n%w(76,4,4)%s%n%n%b" ; The output is: commit 841fd27f1a0ef11a1696e3a5cb6eced316761ee3 tree 369d49618e2752d809ee8807149c402485b8e15b parent b5ad39f1d9c338cb76b2851d8b2ebcef7d59484e author Viacheslav Kopchenin <vkopchenin@odin.com> 2015-10-06T20:09:18+03:00 committer Viacheslav Kopchenin <vkopchenin@odin.com> 2015-10-06T20:09:18+03:00 pom.xml :100644 100644 5868c1b334fdea0d25b21705604e9e1d6f3243b8 56f50739924afe9d151a3c89aa7ace332e55b044 M modules/platform/pom.xml
          Hide
          markewaite Mark Waite added a comment - - edited

          Slava Kopchenin thanks for the output. Unfortunately, as noted in the earlier comment, the

          %cI

          argument is not workable in the git client plugin because the plugin must support git versions prior to git 2.

          We can't abandon support for Red Hat 5, Red Hat 6, Debian 6, and several other working environments which provide git versions prior to git 2.

          Your output is a good source to use to write a test to show the failure and then you could submit a pull request with the test and with code changes to resolve the failure. Even if all you do is write a test to show the failure and submit that as a pull request, that will help move towards an eventual fix for the bug.

          I checked the %cI argument and it is definitely understood by git 2.6.0, but is not understood by git 2.1.4 (Ubuntu 14.04), git 1.9.1 (Debian 8), or git 1.7.1 (CentOS 6.7). Your sample is enough that I was able to create a failing test case to show the problem.

          Show
          markewaite Mark Waite added a comment - - edited Slava Kopchenin thanks for the output. Unfortunately, as noted in the earlier comment , the %cI argument is not workable in the git client plugin because the plugin must support git versions prior to git 2. We can't abandon support for Red Hat 5, Red Hat 6, Debian 6, and several other working environments which provide git versions prior to git 2. Your output is a good source to use to write a test to show the failure and then you could submit a pull request with the test and with code changes to resolve the failure. Even if all you do is write a test to show the failure and submit that as a pull request, that will help move towards an eventual fix for the bug. I checked the %cI argument and it is definitely understood by git 2.6.0, but is not understood by git 2.1.4 (Ubuntu 14.04), git 1.9.1 (Debian 8), or git 1.7.1 (CentOS 6.7). Your sample is enough that I was able to create a failing test case to show the problem.
          Hide
          markewaite Mark Waite added a comment -

          I submitted pull request 355 asking for a review of my proposed fix.

          Show
          markewaite Mark Waite added a comment - I submitted pull request 355 asking for a review of my proposed fix.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Mark Waite
          Path:
          src/main/java/hudson/plugins/git/GitChangeSet.java
          src/test/java/hudson/plugins/git/GitChangeSetBasicTest.java
          src/test/java/hudson/plugins/git/GitChangeSetEmptyTest.java
          src/test/java/hudson/plugins/git/GitChangeSetEuroTest.java
          src/test/java/hudson/plugins/git/GitChangeSetSimpleTest.java
          src/test/java/hudson/plugins/git/GitChangeSetTimestampTest.java
          src/test/java/hudson/plugins/git/GitChangeSetUtil.java
          http://jenkins-ci.org/commit/git-plugin/b84c7c9dcea3a30a87eadb7d20c8be773cab46e3
          Log:
          [Fix JENKINS-30073] changeset time shouldn't be -1

          The changeset time parsing implemented in an earlier commit did not
          account for the most common format of the "nearly ISO" date format
          generated by the "+%ci" format argument.

          The fully ISO 8601 compliant date format argument ( +%cI ) is not
          available in all the git versions supported by the plugin, so the plugin
          continues to use the nearly ISO 8601 compliant format ( +%ci ), then
          transforms it into an ISO 8601 format when the timestamp is requested.

          For example, git 2.1.4 as shipped with Debian 8 does not recognize +%cI
          for date formatting. Git 2.6.0 version does recognizes +%cI.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Mark Waite Path: src/main/java/hudson/plugins/git/GitChangeSet.java src/test/java/hudson/plugins/git/GitChangeSetBasicTest.java src/test/java/hudson/plugins/git/GitChangeSetEmptyTest.java src/test/java/hudson/plugins/git/GitChangeSetEuroTest.java src/test/java/hudson/plugins/git/GitChangeSetSimpleTest.java src/test/java/hudson/plugins/git/GitChangeSetTimestampTest.java src/test/java/hudson/plugins/git/GitChangeSetUtil.java http://jenkins-ci.org/commit/git-plugin/b84c7c9dcea3a30a87eadb7d20c8be773cab46e3 Log: [Fix JENKINS-30073] changeset time shouldn't be -1 The changeset time parsing implemented in an earlier commit did not account for the most common format of the "nearly ISO" date format generated by the "+%ci" format argument. The fully ISO 8601 compliant date format argument ( +%cI ) is not available in all the git versions supported by the plugin, so the plugin continues to use the nearly ISO 8601 compliant format ( +%ci ), then transforms it into an ISO 8601 format when the timestamp is requested. For example, git 2.1.4 as shipped with Debian 8 does not recognize +%cI for date formatting. Git 2.6.0 version does recognizes +%cI.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Mark Waite
          Path:
          src/main/java/hudson/plugins/git/GitChangeSet.java
          src/test/java/hudson/plugins/git/GitChangeSetBasicTest.java
          src/test/java/hudson/plugins/git/GitChangeSetEmptyTest.java
          src/test/java/hudson/plugins/git/GitChangeSetEuroTest.java
          src/test/java/hudson/plugins/git/GitChangeSetPluginHistoryTest.java
          src/test/java/hudson/plugins/git/GitChangeSetSimpleTest.java
          src/test/java/hudson/plugins/git/GitChangeSetTimestampTest.java
          src/test/java/hudson/plugins/git/GitChangeSetUtil.java
          http://jenkins-ci.org/commit/git-plugin/1eda4923300eac714b2fe2027ce7d89d844e32cb
          Log:
          Merge pull request #358 from MarkEWaite/master-JENKINS-30073-timestamp-parsing

          [Fix JENKINS-30073] API timestamp return correct value

          Compare: https://github.com/jenkinsci/git-plugin/compare/4979aced9de7...1eda4923300e

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Mark Waite Path: src/main/java/hudson/plugins/git/GitChangeSet.java src/test/java/hudson/plugins/git/GitChangeSetBasicTest.java src/test/java/hudson/plugins/git/GitChangeSetEmptyTest.java src/test/java/hudson/plugins/git/GitChangeSetEuroTest.java src/test/java/hudson/plugins/git/GitChangeSetPluginHistoryTest.java src/test/java/hudson/plugins/git/GitChangeSetSimpleTest.java src/test/java/hudson/plugins/git/GitChangeSetTimestampTest.java src/test/java/hudson/plugins/git/GitChangeSetUtil.java http://jenkins-ci.org/commit/git-plugin/1eda4923300eac714b2fe2027ce7d89d844e32cb Log: Merge pull request #358 from MarkEWaite/master- JENKINS-30073 -timestamp-parsing [Fix JENKINS-30073] API timestamp return correct value Compare: https://github.com/jenkinsci/git-plugin/compare/4979aced9de7...1eda4923300e
          Hide
          markewaite Mark Waite added a comment - - edited

          Change has merged to the master branch, including tests. The tests show that at least two git older versions (1.7.1 as shipped with CentOS 6 and 1.7.2.5 as shipped with Debian 6) which are known to work in some use cases will show some failures reporting the timestamp of certain commits. The root problem seems to be in the

          git whatchanged
          

          command on those git versions. Newer git versions don't have the problem. Refer to the git plugin source code for more details.

          Will be included in git plugin 2.4.1.

          Show
          markewaite Mark Waite added a comment - - edited Change has merged to the master branch, including tests. The tests show that at least two git older versions (1.7.1 as shipped with CentOS 6 and 1.7.2.5 as shipped with Debian 6) which are known to work in some use cases will show some failures reporting the timestamp of certain commits. The root problem seems to be in the git whatchanged command on those git versions. Newer git versions don't have the problem. Refer to the git plugin source code for more details. Will be included in git plugin 2.4.1.
          Hide
          markewaite Mark Waite added a comment -

          Included in git plugin 2.4.1 released 26 Dec 2015

          Show
          markewaite Mark Waite added a comment - Included in git plugin 2.4.1 released 26 Dec 2015

            People

            • Assignee:
              markewaite Mark Waite
              Reporter:
              stjohn St. John Johnson
            • Votes:
              2 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: