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

‘Pipeline script from SCM’ do not get triggered by github webhooks from the pipeline script repo

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • None
    • Jenkins: 2.204.5
      git plugin: 4.2.2 & 4.4.5
      github plugin: 1.29.5 & 1.32.0

      I have 1 code repo that should be triggering jobs, and a separate repo for a jenkins pipeline library. There are 2 jenkins jobs that use the ‘GitHub hook trigger for GITScm polling’ build trigger, both are pipeline jobs using the ‘Pipeline script from SCM’ with the repository configured to point to the code repo and the ‘Branches to build’ set to ‘origin/develop’. The pipeline library is used inside the pipelines for these jobs.
      I would expect these jobs to have their polling triggered by pushes to the code repo, however they are only being triggered by pushes to the jenkins pipeline library repo.

      Using a log recorder set to get FINEST logs I can see:
      Received PushEvent for https://github.com/<code repo>
      Considering to poke <job>
      Skipped <job> because it doesn't have a matching repository.
      ...
      Received PushEvent for https://github.com/<pipeline library repo>
      Considering to poke <job>
      Poked <job>

      So something in jenkins seems to think these jobs do not use the code repository, but when a scan is triggered I see the following in the ‘Polling Log’:
      Started by event from 192.30.252.97
      ...
      > git ls-remote -h https://github.com/<code repo> # timeout=10
      So the repo poll is using the code repo, and the list of commits that show up in the ‘Changes’ list are from the code repo.
      It seems to be only these 2 jobs that are affected, no other job is being triggered by pushes to the pipeline library repo.

      If I change the job to have the pipeline script entered directly and clone the repo as part of the pipeline it is triggered by the webhook correctly.

      I was able to work around this using the poll scm trigger which will run the job correctly.

          [JENKINS-61494] ‘Pipeline script from SCM’ do not get triggered by github webhooks from the pipeline script repo

          Emma added a comment - - edited

          I'm getting a very similar behaviour in my pipeline script from SCM pipeline job where the job is not getting triggered with the github webhook.

           

          Logs show the following:

          Received PushEvent for https://github.com/<code_repo> from 10.164.202.192 → 140.82.115.150 ⇒ http://<jenkins_url>/jenkins/github-webhook/
          Considering to poke <job>
          Jan 27, 2021 4:24:38 PM FINE org.jenkinsci.plugins.github.webhook.subscriber.DefaultPushGHEventSubscriber$1 runSkipped <job> because it doesn't have a matching repository. 

          Job configuration is as follows:

          Type: Pipeline

          Build Trigger: GitHub hook trigger for GITScm polling

          Pipeline: 

          • Definition: Pipeline from SCM
            • SCM: Git
              • Repo URL: git@github.com:<cope_repo>
              • Credentials: <ssh_key>
            • ScriptPath: Jenkinsfile

          Versions:

          Jenkins - Cloudbees Client Master : v2.263.2.3-rolling

          Git Plugin: 4.4.5

          GitHub Plugin:  1.32.0

           

          GitHub Server System Configuration:

          Name: github

          API URL: https://api.github.com

          Credentials: <github_pat_token>

          Manage Hooks: false (webhooks are configured manually in github)

          GitHub client cache size(MB): 20

          Shared secrets: <secret>

          Emma added a comment - - edited I'm getting a very similar behaviour in my pipeline script from SCM pipeline job where the job is not getting triggered with the github webhook.   Logs show the following: Received PushEvent for https: //github.com/<code_repo> from 10.164.202.192 → 140.82.115.150 ⇒ http://<jenkins_url>/jenkins/github-webhook/ Considering to poke <job> Jan 27, 2021 4:24:38 PM FINE org.jenkinsci.plugins.github.webhook.subscriber.DefaultPushGHEventSubscriber$1 runSkipped <job> because it doesn't have a matching repository. Job configuration is as follows: Type: Pipeline Build Trigger: GitHub hook trigger for GITScm polling Pipeline:  Definition: Pipeline from SCM SCM: Git Repo URL: git@github.com:<cope_repo> Credentials: <ssh_key> ScriptPath: Jenkinsfile Versions: Jenkins - Cloudbees Client Master : v2.263.2.3-rolling Git Plugin: 4.4.5 GitHub Plugin:  1.32.0   GitHub Server System Configuration: Name: github API URL: https://api.github.com Credentials: <github_pat_token> Manage Hooks: false (webhooks are configured manually in github) GitHub client cache size(MB): 20 Shared secrets: <secret>

          Mark Waite added a comment -

          emlr since you're running a CloudBees product, you should be able to contact CloudBees support at https://support.cloudbees.com/ for assistance. I've not done any exploratory testing of this issue, so don't have any hints to offer.

          Mark Waite added a comment - emlr since you're running a CloudBees product, you should be able to contact CloudBees support at https://support.cloudbees.com/ for assistance. I've not done any exploratory testing of this issue, so don't have any hints to offer.

          Chad added a comment -

          I ran into this same issue and found 2 workarounds.

          1. If you set both an SSH github repo and the same HTTPS github repo in the SCM section then hooks will trigger. Strange but works.
          2. Use the following in the triggers section of your pipeline:

           
           

          pipeline {
            agent none
            triggers {
              githubPush()
            }
            stages {
              stage('Integration Test') {
                ...
              }
            }
          }

           

          Chad added a comment - I ran into this same issue and found 2 workarounds. If you set both an SSH github repo and the same HTTPS github repo in the SCM section then hooks will trigger. Strange but works. Use the following in the triggers section of your pipeline:     pipeline { agent none triggers { githubPush() } stages { stage('Integration Test') { ... } } }  

            Unassigned Unassigned
            organised_chaos James Robson
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: