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

inspect github payload and build specific SHAs

      When two or more pushes happen in a small time frame, the github webhook in jenkins triggers multiple builds just fine. However, each of these builds is for the latest SHA in that git repository. Example:

      01:01:01 - User 1 pushes sha #1 to master branch
      01:01:02 - User 2 pushes sha #2 to master branch

      Jenkins receives the two POSTs and triggers two builds. Each of these builds simply does a git pull and starts the build script at sha #2. This has the side effect of never building sha #1 by itself.

      I'm not so great at Java, but looking at the GitHubPushTrigger.java file here:

      https://github.com/jenkinsci/github-plugin/blob/master/src/main/java/com/cloudbees/jenkins/GitHubPushTrigger.java

      It appears to never inspect the payload from the github call. Is it possible to have this code inspect the payload and build based off of the 'after' key? There is an example of the payload here:

      https://help.github.com/articles/post-receive-hooks

      I don't know how possible this is, but it would seem to be a great addition to the github plugin.

          [JENKINS-20518] inspect github payload and build specific SHAs

          Maybe parsing the payload and setting as environment variables could be solved easily using ${sha1} as the branch to build. It is similar as how PRBuilder works.

          Xavier Morales added a comment - Maybe parsing the payload and setting as environment variables could be solved easily using ${sha1} as the branch to build. It is similar as how PRBuilder works.

          yep, this problem discussed already there: JENKINS-27041

          Im working on the solution in my spare time

          Kirill Merkushev added a comment - yep, this problem discussed already there: JENKINS-27041 Im working on the solution in my spare time

          The Git plugin already offers a facility to build the exact sha1 that you pass: https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin#GitPlugin-Pushnotificationfromrepository

          I was really surprised to find out that the GitHub push trigger only triggers a polling instead of (unconditionally) build the sha1/branch specified by the GitHub webhook payload.

          Leandro Lucarella added a comment - The Git plugin already offers a facility to build the exact sha1 that you pass: https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin#GitPlugin-Pushnotificationfromrepository I was really surprised to find out that the GitHub push trigger only triggers a polling instead of (unconditionally) build the sha1/branch specified by the GitHub webhook payload.

          I started writting push trigger under https://github.com/jenkinsci/github-integration-plugin if you would like to test or help with development, then i can push and share my WIP.

          Kanstantsin Shautsou added a comment - I started writting push trigger under https://github.com/jenkinsci/github-integration-plugin if you would like to test or help with development, then i can push and share my WIP.

          Thanks but my java-fu is null to contribute anything (and I'm not planning to get any) and I have a large jenkins installation testing hundreds of projects, so I can't change all my setup to test a completely new plugin. I think I will workaround this problem by using a combination of receiving the github webhook as described in here: http://chloky.com/github-json-payload-in-jenkins/ and then process the payload using a programming language I speak to trigger the build using the trigger URL for the Git plugin.

          Leandro Lucarella added a comment - Thanks but my java-fu is null to contribute anything (and I'm not planning to get any) and I have a large jenkins installation testing hundreds of projects, so I can't change all my setup to test a completely new plugin. I think I will workaround this problem by using a combination of receiving the github webhook as described in here: http://chloky.com/github-json-payload-in-jenkins/ and then process the payload using a programming language I speak to trigger the build using the trigger URL for the Git plugin.

          I was just wondering if anyone else had any updates for this, I've run into basically this exact issue and I'm stuck on how to solve it. I liked the git plugin suggestion but since I'm using hooks from GitHub I can't control the URL to the extent that I would need to for that solution to work.

          Anthony Gargiulo added a comment - I was just wondering if anyone else had any updates for this, I've run into basically this exact issue and I'm stuck on how to solve it. I liked the git plugin suggestion but since I'm using hooks from GitHub I can't control the URL to the extent that I would need to for that solution to work.

            Unassigned Unassigned
            crazed Allan Feid
            Votes:
            5 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: