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

Github webhook ignore "Github project" field (I.E. projectUrl)

    • Icon: Bug Bug
    • Resolution: Incomplete
    • Icon: Minor Minor
    • github-plugin
    • Jenkins 1.623 from deb (Ubuntu Server 15.04)
      Github plugin 1.12.0

      When setting up a Project with "Build when a change is pushed to GitHub" enabled, the webhook handler use the source code repository url to match the github project is applies on and ignore the dedicated field "Github project" (I.E. projectUrl).

      I think this is not a wanted behavior as this field seems to be dedicated to this purpose.

      Additionally this prevent from creating jobs that does not checkout the repository but are still triggered by the github webhook

          [JENKINS-29827] Github webhook ignore "Github project" field (I.E. projectUrl)

          Yes this is what I mean

          Félicien François added a comment - Yes this is what I mean

          think we should add repo name contributor which extracts gh url from property

          Kirill Merkushev added a comment - think we should add repo name contributor which extracts gh url from property

          I thought about replacing SCM parsing usage, but not sure then how git polling/scmNotify should work. I can suggest firstly migrate to commitNotify.

          Kanstantsin Shautsou added a comment - I thought about replacing SCM parsing usage, but not sure then how git polling/scmNotify should work. I can suggest firstly migrate to commitNotify.

          Kirill Merkushev added a comment - - edited

          Félicien François, by default build is triggered only if scm change detected. So it never worked before with property only.

          Kirill Merkushev added a comment - - edited Félicien François, by default build is triggered only if scm change detected. So it never worked before with property only.

          Félicien François added a comment - - edited

          Yes I know but I think this is an issue.
          I'll try to explain:

          1°) First, this would be a strong added value. For now the only added value is a slight performance improvement, allowing to use webhooks instead of polling to detect scm changes.
          I'm talking about changing it into a useful feature by allowing to create jobs that does not checkout the repository but are still triggered by the github webhook.

          2°) For now the design of this feature is wrong. There is a trigger "Build when a change is pushed to GitHub". I'm expecting that the build is triggered when a change is pushed to github (not to the scm of my project). If you want to keep on the scm change, the trigger should be the default trigger (build on scm change) and then handle triggering of the scm change event through webhook, either by a hook into git scm management or by creating a new type of scm manager "Github"

          3°) Without this feature, the "Github project" field seems to be useless, maybe only used for some links ? If you consider Github = SCM, why is there such a "Github project" field ? why don't you use the scm setting for all github related things ?

          4°) This change does not need to be a breaking one. The rule can be: when receiving a webhook, looks into "Github project" AND in scm(s) urls. This way, old configurations would continue to work after the update

          Félicien François added a comment - - edited Yes I know but I think this is an issue. I'll try to explain: 1°) First, this would be a strong added value. For now the only added value is a slight performance improvement, allowing to use webhooks instead of polling to detect scm changes. I'm talking about changing it into a useful feature by allowing to create jobs that does not checkout the repository but are still triggered by the github webhook. 2°) For now the design of this feature is wrong. There is a trigger "Build when a change is pushed to GitHub". I'm expecting that the build is triggered when a change is pushed to github (not to the scm of my project). If you want to keep on the scm change, the trigger should be the default trigger (build on scm change) and then handle triggering of the scm change event through webhook, either by a hook into git scm management or by creating a new type of scm manager "Github" 3°) Without this feature, the "Github project" field seems to be useless, maybe only used for some links ? If you consider Github = SCM, why is there such a "Github project" field ? why don't you use the scm setting for all github related things ? 4°) This change does not need to be a breaking one. The rule can be: when receiving a webhook, looks into "Github project" AND in scm(s) urls. This way, old configurations would continue to work after the update

          Nothing wrong It works how designed by author.

          Github project is used for linking and by some gh related plugins.

          We plan implement more generic GH triggers that shouldn't depend on SCM, adding hacks right now is bad idea.

          Kanstantsin Shautsou added a comment - Nothing wrong It works how designed by author. Github project is used for linking and by some gh related plugins. We plan implement more generic GH triggers that shouldn't depend on SCM, adding hacks right now is bad idea.

          Félicien François, thanks for your feedback!

          This problem already mentioned in https://github.com/jenkinsci/github-plugin/pull/54
          We are working on it

          Kirill Merkushev added a comment - Félicien François, thanks for your feedback! This problem already mentioned in https://github.com/jenkinsci/github-plugin/pull/54 We are working on it

          OK, thank you Kirill and good luck.

          Félicien François added a comment - OK, thank you Kirill and good luck.

          Is there any update regarding this issue?

          Today I realised that the github plugin doesn’t automatically create the github webhook for my pipeline job which is configured to fetch the pipeline script from SCM. I guess github plugin doesn’t look at the pipeline script SCM settings and consequently can’t register the webhook.

          To reproduce this you can run the following script in the jenkins script console:

          import com.cloudbees.jenkins.GitHubWebHook
          import jenkins.model.Jenkins
          
          def myPipelineJob = Jenkins.getInstance().getAllItems().find { it.name == 'my-pipeline' }
          GitHubWebHook.get().registerHookFor(myPipelineJob)
          

          then jenkins logs shows the following:

          Jul 10, 2016 2:16:51 AM INFO org.jenkinsci.plugins.github.webhook.WebhookManager$1 run
          GitHub webhooks activated for job my-pipeline with [] (events: [PUSH])
          

          As you can see, there are no repository information thus no webhook was created.

          When I do the same for a freestyle job, then everything works and the log output looks like this:

          Jul 10, 2016 2:20:26 AM INFO org.jenkinsci.plugins.github.webhook.WebhookManager$1 run
          GitHub webhooks activated for job freestyle-job with [GitHubRepositoryName[host=my-corp-github-enterprise.com,username=foo,repository=bar]] (events: [PUSH])
          

          Mathias Schreck added a comment - Is there any update regarding this issue? Today I realised that the github plugin doesn’t automatically create the github webhook for my pipeline job which is configured to fetch the pipeline script from SCM. I guess github plugin doesn’t look at the pipeline script SCM settings and consequently can’t register the webhook. To reproduce this you can run the following script in the jenkins script console: import com.cloudbees.jenkins.GitHubWebHook import jenkins.model.Jenkins def myPipelineJob = Jenkins.getInstance().getAllItems().find { it.name == 'my-pipeline' } GitHubWebHook.get().registerHookFor(myPipelineJob) then jenkins logs shows the following: Jul 10, 2016 2:16:51 AM INFO org.jenkinsci.plugins.github.webhook.WebhookManager$1 run GitHub webhooks activated for job my-pipeline with [] (events: [PUSH]) As you can see, there are no repository information thus no webhook was created. When I do the same for a freestyle job, then everything works and the log output looks like this: Jul 10, 2016 2:20:26 AM INFO org.jenkinsci.plugins.github.webhook.WebhookManager$1 run GitHub webhooks activated for job freestyle-job with [GitHubRepositoryName[host=my-corp-github-enterprise.com,username=foo,repository=bar]] (events: [PUSH])

          So it works fine with freestyle job but doesn't with pipeline?

          Kanstantsin Shautsou added a comment - So it works fine with freestyle job but doesn't with pipeline?

            lanwen Kirill Merkushev
            felicienfrancois Félicien François
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: