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

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

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Component/s: git-plugin
    • Environment:
      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
    • Similar Issues:

      Description

      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...

        Attachments

          Activity

          Hide
          tzachz Tzach Zohar added a comment -

          Hi Or -
          I seem to be having the same issue (getting the "First time build. Skipping changelog" message, not seeing changes recorded, although not first build). Any luck figuring it out?

          My relevant jobs are all using the Job DSL Plugin, I suspect it has to do with that plugin "recreating" the job between runs (making each run practically "first"), though I haven't been able to prove it yet. I'm curious - are your builds using this plugin too?

          Thanks,
          Tzach (צח)

          Show
          tzachz Tzach Zohar added a comment - Hi Or - I seem to be having the same issue (getting the "First time build. Skipping changelog" message, not seeing changes recorded, although not first build). Any luck figuring it out? My relevant jobs are all using the Job DSL Plugin , I suspect it has to do with that plugin "recreating" the job between runs (making each run practically "first"), though I haven't been able to prove it yet. I'm curious - are your builds using this plugin too? Thanks, Tzach (צח)
          Hide
          pixman20 pixman20 added a comment -

          I just ran into this and it ended up being because I was using a shallow clone.
          I'm not entirely sure why that matters, because I believe I've used it before without any issue, though I can't find an example right now.
          If anyone else runs into this, see if you can remove the shallow clone option or try removing any other Git plugin options that could be causing this issue.

          Show
          pixman20 pixman20 added a comment - I just ran into this and it ended up being because I was using a shallow clone. I'm not entirely sure why that matters, because I believe I've used it before without any issue, though I can't find an example right now. If anyone else runs into this, see if you can remove the shallow clone option or try removing any other Git plugin options that could be causing this issue.
          Hide
          c3zi Przemyslaw Furtak added a comment - - edited

          I have the same problem. I use JIRA-Plugin to send a comment at the end of one of my job. I use a bitbucket pull request as a trigger. The first time when the job is created i see in my console log the message:
          "First time build. Skipping changelog."
          and then at the end of console logs i see:
          "[JIRA] Setting JIRA_ISSUES to ."
          It means that JIRA Plugin didn't find any issue id in commits.

          But when I add a new commit to the same Pull Request and the job is rebuilt I see in the console logs:
          "git rev-list 0d26fc7c033d3ceb4ceaee8225941d75cf6783ea # timeout=10".
          At the end of the console logs I see:
          "[JIRA] Setting JIRA_ISSUES to MYPROJECT-639."
          It means that issue id is found properly in the commit.

          I guess that it is related with "no changes" message, but i'm not sure where i should write my comment:

          • here
          • jira-plugin bugtracker
          • bitbucket pull request bugtracker

          Any ideas?

          Show
          c3zi Przemyslaw Furtak added a comment - - edited I have the same problem. I use JIRA-Plugin to send a comment at the end of one of my job. I use a bitbucket pull request as a trigger. The first time when the job is created i see in my console log the message: "First time build. Skipping changelog." and then at the end of console logs i see: " [JIRA] Setting JIRA_ISSUES to ." It means that JIRA Plugin didn't find any issue id in commits. But when I add a new commit to the same Pull Request and the job is rebuilt I see in the console logs: "git rev-list 0d26fc7c033d3ceb4ceaee8225941d75cf6783ea # timeout=10". At the end of the console logs I see: " [JIRA] Setting JIRA_ISSUES to MYPROJECT-639." It means that issue id is found properly in the commit. I guess that it is related with "no changes" message, but i'm not sure where i should write my comment: here jira-plugin bugtracker bitbucket pull request bugtracker Any ideas?
          Hide
          slavik334 Viachaslau Kabak added a comment -

          facing the same issue
          jenkins1.651.3

          Show
          slavik334 Viachaslau Kabak added a comment - facing the same issue jenkins1.651.3
          Hide
          danito8905 Daniel Nuss added a comment - - edited

          Hi, I had the same problem.
          I solve it, making a new job copying the existing one and remove then the original.

          In the new copied job, the changelog work correctly.

          I hope this helps.

          Jenkins 1.651.1

          Show
          danito8905 Daniel Nuss added a comment - - edited Hi, I had the same problem. I solve it, making a new job copying the existing one and remove then the original. In the new copied job, the changelog work correctly. I hope this helps. Jenkins 1.651.1
          Hide
          nileshpatelmca Nilesh Patel added a comment -

          Does issue solve for anyone ?

           

          Show
          nileshpatelmca Nilesh Patel added a comment - Does issue solve for anyone ?  

            People

            • Assignee:
              Unassigned
              Reporter:
              or_shachar Or Shachar
            • Votes:
              4 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

              • Created:
                Updated: