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

Git plugin doesn't parse changelog (false "First time build")

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • git-plugin
    • Jenkins 1.565.2, 1.580.3
      Git-Client 1.11.0, 1.14.1
      Git plugin 2.2.7, 2.3.4
      SCM-API 0.2

      Both master and slave works on RHEL 6.3 with Java 7u51

      The job is triggered because of SCM change:

      Poll log
      [poll] Last Built Revision: Revision 3281126a340c0e863f12c11a7f9ccd31bceb587a (origin/master)
      [git] $ sh -e /DATA/jenkins/app-data/tools/git/hudson598255919908413882.sh
       > git ls-remote -h [CENSURED] master # timeout=10
      [poll] Latest remote head revision is: e72acfe796b818f51ba549991a8f1876657d8986
      Done. Took 0.32 sec
      Changes found
      

      But in the run git log we see that it skips changelog becuase of "First time build" -falsely:

      Run log
      16:27:52  > /usr/bin/git checkout -f e72acfe796b818f51ba549991a8f1876657d8986
      16:27:55  > /usr/bin/git rev-list 3281126a340c0e863f12c11a7f9ccd31bceb587a # timeout=10
      16:27:55 First time build. Skipping changelog.
      

      Looking at the current code of Git Plugin I see there's some kind of condition on "exclusion" but I've yet understood what sets it:

      from GitSCM.java
        private void computeChangeLog(GitClient git, Revision revToBuild, TaskListener listener, BuildData previousBuildData, FilePath changelogFile, BuildChooserContext context) throws IOException, InterruptedException {
              Writer out = new OutputStreamWriter(changelogFile.write(),"UTF-8");
      
              boolean executed = false;
              ChangelogCommand changelog = git.changelog();
              changelog.includes(revToBuild.getSha1());
              try {
                  boolean exclusion = false;
                  ChangelogToBranch changelogToBranch = getExtensions().get(ChangelogToBranch.class);
                  if (changelogToBranch != null) {
                      listener.getLogger().println("Using 'Changelog to branch' strategy.");
                      changelog.excludes(changelogToBranch.getOptions().getRef());
                      exclusion = true;
                  } else {
                      for (Branch b : revToBuild.getBranches()) {
                          Build lastRevWas = getBuildChooser().prevBuildForChangelog(b.getName(), previousBuildData, git, context);
                          if (lastRevWas != null && git.isCommitInRepo(lastRevWas.getSHA1())) {
                              changelog.excludes(lastRevWas.getSHA1());
                              exclusion = true;
                          }
                      }
                  }
      
                  if (!exclusion) {
                      // this is the first time we are building this branch, so there's no base line to compare against.
                      // if we force the changelog, it'll contain all the changes in the repo, which is not what we want.
                      listener.getLogger().println("First time build. Skipping changelog.");
                  } else {
                      changelog.to(out).max(MAX_CHANGELOG).execute();
                      executed = true;
                  }
              } catch (GitException ge) {
                  ge.printStackTrace(listener.error("Unable to retrieve changeset"));
              } finally {
                  if (!executed) changelog.abort();
                  IOUtils.closeQuietly(out);
              }
          }
      

      I might take the task to fix it on my own - but maybe for some of you it may be obvious...

          [JENKINS-25508] Git plugin doesn't parse changelog (false "First time build")

          Or Shachar created issue -
          Or Shachar made changes -
          Description Original: The job is triggered because of SCM change:
          {code:title=Poll log|borderStyle=solid}
          [poll] Last Built Revision: Revision 3281126a340c0e863f12c11a7f9ccd31bceb587a (origin/master)
          [git] $ sh -e /DATA/jenkins/app-data/tools/git/hudson598255919908413882.sh
           > git ls-remote -h [CENSURED] master # timeout=10
          [poll] Latest remote head revision is: e72acfe796b818f51ba549991a8f1876657d8986
          Done. Took 0.32 sec
          Changes found
          {code}
          But in the git log we see that it skips changelog becuase of "First time build" -falsely:
          {code:title=Run log|borderStyle=solid}
          16:27:52 > /usr/bin/git checkout -f e72acfe796b818f51ba549991a8f1876657d8986
          16:27:55 > /usr/bin/git rev-list 3281126a340c0e863f12c11a7f9ccd31bceb587a # timeout=10
          16:27:55 First time build. Skipping changelog.
          {code}

          Looking at the current code of Git Plugin I see there's some kind of condition on "exclusion" but I've yet understood what sets it:

          {code:java|title=from GitSCM.java}
            private void computeChangeLog(GitClient git, Revision revToBuild, TaskListener listener, BuildData previousBuildData, FilePath changelogFile, BuildChooserContext context) throws IOException, InterruptedException {
                  Writer out = new OutputStreamWriter(changelogFile.write(),"UTF-8");

                  boolean executed = false;
                  ChangelogCommand changelog = git.changelog();
                  changelog.includes(revToBuild.getSha1());
                  try {
                      boolean exclusion = false;
                      ChangelogToBranch changelogToBranch = getExtensions().get(ChangelogToBranch.class);
                      if (changelogToBranch != null) {
                          listener.getLogger().println("Using 'Changelog to branch' strategy.");
                          changelog.excludes(changelogToBranch.getOptions().getRef());
                          exclusion = true;
                      } else {
                          for (Branch b : revToBuild.getBranches()) {
                              Build lastRevWas = getBuildChooser().prevBuildForChangelog(b.getName(), previousBuildData, git, context);
                              if (lastRevWas != null && git.isCommitInRepo(lastRevWas.getSHA1())) {
                                  changelog.excludes(lastRevWas.getSHA1());
                                  exclusion = true;
                              }
                          }
                      }

                      if (!exclusion) {
                          // this is the first time we are building this branch, so there's no base line to compare against.
                          // if we force the changelog, it'll contain all the changes in the repo, which is not what we want.
                          listener.getLogger().println("First time build. Skipping changelog.");
                      } else {
                          changelog.to(out).max(MAX_CHANGELOG).execute();
                          executed = true;
                      }
                  } catch (GitException ge) {
                      ge.printStackTrace(listener.error("Unable to retrieve changeset"));
                  } finally {
                      if (!executed) changelog.abort();
                      IOUtils.closeQuietly(out);
                  }
              }
          {code}

          I might take the task to fix it on my own - but maybe for some of you it may be obvious...
          New: The job is triggered because of SCM change:
          {code:title=Poll log|borderStyle=solid}
          [poll] Last Built Revision: Revision 3281126a340c0e863f12c11a7f9ccd31bceb587a (origin/master)
          [git] $ sh -e /DATA/jenkins/app-data/tools/git/hudson598255919908413882.sh
           > git ls-remote -h [CENSURED] master # timeout=10
          [poll] Latest remote head revision is: e72acfe796b818f51ba549991a8f1876657d8986
          Done. Took 0.32 sec
          Changes found
          {code}
          But in the run git log we see that it skips changelog becuase of "First time build" -falsely:
          {code:title=Run log|borderStyle=solid}
          16:27:52 > /usr/bin/git checkout -f e72acfe796b818f51ba549991a8f1876657d8986
          16:27:55 > /usr/bin/git rev-list 3281126a340c0e863f12c11a7f9ccd31bceb587a # timeout=10
          16:27:55 First time build. Skipping changelog.
          {code}

          Looking at the current code of Git Plugin I see there's some kind of condition on "exclusion" but I've yet understood what sets it:

          {code:java|title=from GitSCM.java}
            private void computeChangeLog(GitClient git, Revision revToBuild, TaskListener listener, BuildData previousBuildData, FilePath changelogFile, BuildChooserContext context) throws IOException, InterruptedException {
                  Writer out = new OutputStreamWriter(changelogFile.write(),"UTF-8");

                  boolean executed = false;
                  ChangelogCommand changelog = git.changelog();
                  changelog.includes(revToBuild.getSha1());
                  try {
                      boolean exclusion = false;
                      ChangelogToBranch changelogToBranch = getExtensions().get(ChangelogToBranch.class);
                      if (changelogToBranch != null) {
                          listener.getLogger().println("Using 'Changelog to branch' strategy.");
                          changelog.excludes(changelogToBranch.getOptions().getRef());
                          exclusion = true;
                      } else {
                          for (Branch b : revToBuild.getBranches()) {
                              Build lastRevWas = getBuildChooser().prevBuildForChangelog(b.getName(), previousBuildData, git, context);
                              if (lastRevWas != null && git.isCommitInRepo(lastRevWas.getSHA1())) {
                                  changelog.excludes(lastRevWas.getSHA1());
                                  exclusion = true;
                              }
                          }
                      }

                      if (!exclusion) {
                          // this is the first time we are building this branch, so there's no base line to compare against.
                          // if we force the changelog, it'll contain all the changes in the repo, which is not what we want.
                          listener.getLogger().println("First time build. Skipping changelog.");
                      } else {
                          changelog.to(out).max(MAX_CHANGELOG).execute();
                          executed = true;
                      }
                  } catch (GitException ge) {
                      ge.printStackTrace(listener.error("Unable to retrieve changeset"));
                  } finally {
                      if (!executed) changelog.abort();
                      IOUtils.closeQuietly(out);
                  }
              }
          {code}

          I might take the task to fix it on my own - but maybe for some of you it may be obvious...
          Or Shachar made changes -
          Environment Original: Jenkins 1.565.2
          Git-Client 1.11.0
          Git plugin 2.2.7
          SCM-API 0.2
          SSH credentials 1.10
          Credentials 1.18

          Both master and slave works on RHEL 6.3 with Java 7u51
          New: Jenkins 1.565.2, 1.580.3
          Git-Client 1.11.0, 1.14.1
          Git plugin 2.2.7, 2.3.4
          SCM-API 0.2

          Both master and slave works on RHEL 6.3 with Java 7u51
          Or Shachar made changes -
          Priority Original: Minor [ 4 ] New: Major [ 3 ]
          R. Tyler Croy made changes -
          Workflow Original: JNJira [ 159476 ] New: JNJira + In-Review [ 179994 ]
          Nicolas De Loof made changes -
          Assignee Original: Nicolas De Loof [ ndeloof ]

            Unassigned Unassigned
            or_shachar Or Shachar
            Votes:
            5 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated: