• Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • git-plugin
    • Git Plugin 4.10.3

      The first build of a Pull Request reports no changes since last build.  I found this same issue closed due to no response https://issues.jenkins.io/browse/JENKINS-26354.

      In trying to automate builds based on change content, this issue is problematic.  Because the "first build" of a pull request (change request) reports that there is no changelog, there is no way for the job to know what file types changed.  It seems to me that the compare for the first job of a pull request should be comparing itself against the branch point.  For example, getting the branch point, and then looking for commits in the branch since that point with something like:

      branch_commit = git merge-base ${main} ${branch_name}
      commits_since_branch = git log ${branch_commit}..${branch_name}
      

      From original post, as it describes my issue perfectly:

      Suppose, we have master branch. Then we checkout to a new branch, lets name it branch1:

      git checkout -b branch1
      

      Then we do some commits:

      echo "a" > a.txt && git add a.txt && git commit -m 'Added file: a.txt'
      echo "b" > b.txt && git add b.txt && git commit -m 'Added file: b.txt'
      

      Then we push our branch to Git repository:

      git push origin branch1
      

      In Jenkins, Git polling reports:

      ...
      Seen branch in repository origin/branch1
      Seen XXX remote branches
       > /usr/bin/git log --full-history --no-abbrev --format=raw -M -m --raw 0a6eb107fea5bb6371c450db1b5f6e100e0fba28..d8c5018ca184fb75e46386de2f16e552906fe106 # timeout=10
      Done. Took 3.5 sec
      Changes found
      

      but Changes section shows nothing, it means, that no changes were made. Nevertheless, build was triggered.

          [JENKINS-68030] PR first time build has no changelog

          Mark Waite added a comment -

          Git does not have a concept of a branch point. The pull request merged into git plugin 5.3.0 will allow the user to optionally declare that if this is the first build of a branch, show the most recent commit on that branch as the changelog. That is not the set of all commits since a branch point, just the most recent commit.

          Mark Waite added a comment - Git does not have a concept of a branch point. The pull request merged into git plugin 5.3.0 will allow the user to optionally declare that if this is the first build of a branch, show the most recent commit on that branch as the changelog. That is not the set of all commits since a branch point, just the most recent commit.

          Derek Sharpe added a comment - - edited

          While Git doesn't call out the concept in documentation, it seems like it does have the concept or at least a very close cousin.  For example, either of the following commands will print the commits in the branch since it was branched from origin.

          git log HEAD ^origin

          git log origin..HEAD

          Derek Sharpe added a comment - - edited While Git doesn't call out the concept in documentation, it seems like it does have the concept or at least a very close cousin.  For example, either of the following commands will print the commits in the branch since it was branched from origin. git log HEAD ^origin git log origin..HEAD

          Mark Waite added a comment -

          print the commits in the branch since it was branched from origin.

          The commit has no record of the base of its branch. I have several repositories that actively maintain multiple branches with branching from any of them and merging into any of them. While git log HEAD ^master can list the commits between HEAD and master, it can't tell me if the last argument in that command should be master or stable-2.462 or stable-2.453.

          Mark Waite added a comment - print the commits in the branch since it was branched from origin. The commit has no record of the base of its branch. I have several repositories that actively maintain multiple branches with branching from any of them and merging into any of them. While git log HEAD ^master can list the commits between HEAD and master, it can't tell me if the last argument in that command should be master or stable-2.462 or stable-2.453 .

            Unassigned Unassigned
            dereksharpe Derek Sharpe
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: