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

GitHub plugin build-on-push for Pipeline job is hard/unpredictable to work with

      Hello,
      I have encountered issues with automatic hook registering for a pipeline job.

      This is the github project:

      https://github.com/alanfranz/foolscrate

      I have read:

      https://issues.jenkins-ci.org/browse/JENKINS-37217

      and

      https://issues.jenkins-ci.org/browse/JENKINS-34396

      I created a new pipeline job, I did set the github project url, checked "build when change is pushed to github", then choose to use the Jenkinsfile from SCM, and set the github ssh url for my project; Initially I had an issue with the auto-registering of any hook, this was the log

      Aug 31, 2016 10:40:38 AM FINE com.cloudbees.jenkins.GitHubWebHook$1 apply
      Calling registerHooks() for foolscrate-v1dev
      Aug 31, 2016 10:40:38 AM INFO org.jenkinsci.plugins.github.webhook.WebhookManager$1 run
      GitHub webhooks activated for job foolscrate-v1dev with [] (events: [REPOSITORY])
      

      There were no hooks defined in my github settings page for the repo.

      After looking at the issues above, I discovered that I had to manually trigger one build and I needed to set (AFAICU) an explit 'git url:' in my Jenkinsfile. THEN, after that, I had to disable the "Build when change was pushed to github", save the job, RE-ENABLE the option, re-save the job.

      After doing that, this was the log:

      Aug 31, 2016 10:59:42 AM INFO org.jenkinsci.plugins.github.webhook.WebhookManager$1 run
      GitHub webhooks activated for job foolscrate-v1dev with [GitHubRepositoryName[host=github.com,username=alanfranz,repository=foolscrate]] (events: [REPOSITORY])
      Aug 31, 2016 10:59:43 AM FINE org.jenkinsci.plugins.github.webhook.WebhookManager$3 applyNullSafe
      Created hook https://api.github.com/repos/alanfranz/foolscrate/hooks/9722521 (events: [REPOSITORY])
      Aug 31, 2016 11:00:06 AM FINE org.jenkinsci.plugins.github.webhook.WebhookManager unregisterFor
      Check GHRepository@20f660a4[description=<null>,homepage=<null>,name=foolscrate,license=<null>,fork=false,watchers=0,forks=0,size=66,milestones={},language=Shell,commits={},source=<null>,parent=<null>,url=https://api.github.com/repos/alanfranz/foolscrate,id=65638029] for redundant hooks...
      

      And still nothing happened on push.

      See the issue? It seems the hook was created only for REPOSITORY events, but not for PUSH events!

      I entered my github settings page, and enabled the PUSH event.

      Immediately, the event was triggered and the build started. But something more happened:

       SCM changes detected in foolscrate-v1dev. Triggering #4
      Aug 31, 2016 11:13:59 AM FINE com.cloudbees.jenkins.GitHubWebHook$1 apply
      Calling registerHooks() for foolscrate-v1dev
      Aug 31, 2016 11:13:59 AM INFO org.jenkinsci.plugins.github.webhook.WebhookManager$1 run
      GitHub webhooks activated for job foolscrate-v1dev with [GitHubRepositoryName[host=github.com,username=alanfranz,repository=foolscrate]] (events: [PUSH, REPOSITORY])
      Aug 31, 2016 11:13:59 AM FINE org.jenkinsci.plugins.github.webhook.WebhookManager$3 applyNullSafe
      Created hook https://api.github.com/repos/alanfranz/foolscrate/hooks/9722695 (events: [PUSH, REPOSITORY])

      That happened WITHOUT me editing the job itself again (I had committed changes to the Jenkinsfile, by the way), and now the hook seemed to register properly.

      My final request:
      I'm not sure whether this is a bug; the pipeline job should now be the "way to go" for new Jenkins job. Can we get a CLEAR documentation of what we should or shouldn't do, in either the Jenkins page or the Jenkinsfile, in order to make Github push events to work?

      Thank you very much!

          [JENKINS-37845] GitHub plugin build-on-push for Pipeline job is hard/unpredictable to work with

          github plugin provides only simple trigger that kicks GitSCM.poll() if you expect something other for Jenkinsfiles/workflows then it not github-plugin issue. choose Jenkinsfile also has no relation, probably you are using CB plugins, reassigned.

          Kanstantsin Shautsou added a comment - github plugin provides only simple trigger that kicks GitSCM.poll() if you expect something other for Jenkinsfiles/workflows then it not github-plugin issue. choose Jenkinsfile also has no relation, probably you are using CB plugins, reassigned.

          The GitHub Org Folders plugin is being tombstoned.

          The functionality provided by the GitHub Org Folders plugin has been significantly refactored and migrated to the GitHub Branch Source plugin.

          Please verify if this issue is an issue with GitHub Branch Source 2.0.0-beta-1 (available from the experimental update center now or 2.0.0 (available in early January 2017)

          Stephen Connolly added a comment - The GitHub Org Folders plugin is being tombstoned. The functionality provided by the GitHub Org Folders plugin has been significantly refactored and migrated to the GitHub Branch Source plugin. Please verify if this issue is an issue with GitHub Branch Source 2.0.0-beta-1 (available from the experimental update center now or 2.0.0 (available in early January 2017)

          I confirm this strange behavior. I used a fresh Jenkins 2.32.1 installed today with all Git/Plugins updated to their latest version before writing a new pipeline.
          To make the hook registering to work, I must run the pipeline first time ensuring a first checkout is performed.
          Once it is done, i disable GitHub hook trigger for GITScm polling option, save the job , re-enable the option and save again the job. Registration is done (i can see the webhook on githib project settings) and now the pipeline can be triggered.

          If is the expected process to register the hook, it should be documented clearly....

          Laurent TOURREAU added a comment - I confirm this strange behavior. I used a fresh Jenkins 2.32.1 installed today with all Git/Plugins updated to their latest version before writing a new pipeline. To make the hook registering to work, I must run the pipeline first time ensuring a first checkout is performed. Once it is done, i disable GitHub hook trigger for GITScm polling option, save the job , re-enable the option and save again the job. Registration is done (i can see the webhook on githib project settings) and now the pipeline can be triggered. If is the expected process to register the hook, it should be documented clearly....

          The hook should be registered on first index/scan (assuming the scan credentials have permission to register the hook)

          Stephen Connolly added a comment - The hook should be registered on first index/scan (assuming the scan credentials have permission to register the hook)

          With GitHub Branch Source v2.0.4 I'm not seeing it either 1) create the hook (if missing), even on first index/scan, nor 2) do I see it update hooks.

          At the moment, I'm manually creating the webhooks with the events: push, repository, and pull-request (see JENKINS-39025 for why).

          I've tried new GitHub Org Folders, editing existing GH Org Folders, etc. and it never seems to register the webhook anymore.

          Christian Höltje added a comment - With GitHub Branch Source v2.0.4 I'm not seeing it either 1) create the hook (if missing), even on first index/scan, nor 2) do I see it update hooks. At the moment, I'm manually creating the webhooks with the events: push , repository , and pull-request (see JENKINS-39025 for why). I've tried new GitHub Org Folders, editing existing GH Org Folders, etc. and it never seems to register the webhook anymore.

          Is this an Org folder or a Multi-branch project.

          If it is a Multi-branch project, then the GitHub plugin is responsible for setting the repository hook.

          If it is an Org folder then the GitHub Branch Source is responsible for setting the organization hook. If there is a file JENKINS_HOME/github-webhooks/GitHubOrgHook.(orgname) then it will not try to register the org hook. Deleting the file and re-saving the organization should trigger a new hook registration attempt

          Stephen Connolly added a comment - Is this an Org folder or a Multi-branch project. If it is a Multi-branch project, then the GitHub plugin is responsible for setting the repository hook. If it is an Org folder then the GitHub Branch Source is responsible for setting the organization hook. If there is a file JENKINS_HOME/github-webhooks/GitHubOrgHook.(orgname) then it will not try to register the org hook. Deleting the file and re-saving the organization should trigger a new hook registration attempt

            stephenconnolly Stephen Connolly
            alanfranz alanfranz
            Votes:
            8 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: