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

GitHub Plugin uses wrong commit SHA for posting commit status

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • github-plugin
    • None
    • Jenkins: 2.263.1
      GitHub plugin: 1.32.0
      Generic Webhook Trigger Plugin: 1.72

      I have a freestyle project setup to be triggered by Generic Webhook Trigger Plugin (not GitHub Plugin) when a pull request is submitted. Everything works fine except posting the commit status on the github at the end of the build. I'm using the "Set GitHub commit status (universal)" option in the "Post-build Actions" with the following settings:

      Commit SHA: Last build revision

      Repositories: Any defined in job repository

      Commit context: Manually entered context name

          Context name: jenkins/linux-s390x

      Status result: One of default messages and statuses

      Status backref: Backref to the build

      Here are some relevant console output:

      Fetching upstream changes from
      https://github.com/s390xlinux/jenkins-test.git
      > /usr/bin/git fetch --tags --force --progress --depth=1 –
      https://github.com/s390xlinux/jenkins-test.git
      +refs/pull/:refs/remotes/origin/pr/ # timeout=10
      > /usr/bin/git rev-parse refs/remotes/origin/pr/12/merge^{commit} # timeout=10
      Checking out Revision 25ca6251a0d9a307c311c1f4c24d076a395a1576 (refs/remotes/origin/pr/12/merge)
      > /usr/bin/git config core.sparsecheckout # timeout=10
      > /usr/bin/git checkout -f 25ca6251a0d9a307c311c1f4c24d076a395a1576 # timeout=10
      Commit message: "Merge b2d4ecc027efa0418984333df6a9c8d6e198869c into d7e4e67f32f97ccb42d5782c655ece32af2867d7"

      ...
       
      [Set GitHub commit status (universal)] SUCCESS on repos [GHRepository@7bab2aca[nodeId=MDEwOlJlcG9zaXRvcnkyNTkxNzYyNDM=,description=<null>,homepage=<null>,name=jenkins-test,license=<null>,fork=false,archived=false,size=15,milestones={},language=Shell,commits={},source=<null>,parent=<null>,isTemplate=<null>,url=https://api.github.com/repos/s390xlinux/jenkins-test,id=259176243,nodeId=<null>,createdAt=2020-04-27T01:46:14Z,updatedAt=2021-01-13T06:55:14Z]] (sha:25ca625) with context:jenkins/linux-s390x
      Setting commit status on GitHub for https://github.com/s390xlinux/jenkins-test/commit/25ca6251a0d9a307c311c1f4c24d076a395a1576
      Finished: SUCCESS

      As you can see, 25ca625 is the SHA for the pull request and b2d4ecc is the SHA for the actual branch to be merged. The correct SHA for the commit status should be the latter.

      On a side note, the same job triggered by the Github Pull Request Builder Plugin gets the correct commit SHA b2d4ecc for posting commit status. Unfortunately I need the Generic Webhook Trigger Plugin for other functionalities.

      The branch to be merged is from a fork of the original repo. Not sure if this is causing the trouble.

            lanwen Kirill Merkushev
            gongsu Gong
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: