2

I have setup a github webhook and also setup logs on the github plugin in jenkins. Jenkins seems to receive correct payload on the webhook. However the log says that github webhook considered poking my job and then after that it skips because it didn't find a matching repository

I am on jenkins 2.1 and recently migrated to 2.5

Received POST for https://github.com/<org_name>/<repo_name>
May 20, 2016 3:17:49 PM FINE  org.jenkinsci.plugins.github.webhook.subscriber.DefaultPushGHEventSubscriber$1 run
Considering to poke echo_pipeline
May 20, 2016 3:17:49 PM FINE org.jenkinsci.plugins.github.webhook.subscriber.DefaultPushGHEventSubscriber$1 run
Skipped echo_pipeline because it doesn't have a matching repository.

I have added this repository in the configuration of the job for pipeline and I am also cloning this repository in the pipeline. Where else do I need to configure repository so that the webhook considers this and doesn't skip it

Pankaj Lal
  • 231
  • 1
  • 3
  • 6
  • I'm having this problem also. It looks like github-plugin doesn't work with the new Jenkins 2.x Pipeline builds. I think there are several JIRA issuesa bout this, but here's one that I found first: https://issues.jenkins-ci.org/browse/JENKINS-35132 – chadmyers Oct 11 '16 at 20:35
  • I gave up on jenkins a few days after this as it just seems to have the wrong architecture of continuous delivery pipelines. we are now on go.cd – Pankaj Lal Oct 12 '16 at 15:23

1 Answers1

4

I know this is an old thread but for the benefit of those who end up here:

1) Your job has to have run at least once manually before the hook will work

2) The repo pushing to Jenkins, the GitHub project url in the project configuration, and the repo(s) in your pipeline Job have to line up.

3) You need a log recorder in Jenkins to see what's being sent by GitHub: https://support.cloudbees.com/hc/en-us/articles/204880580-How-do-I-create-a-logger-in-Jenkins-for-troubleshooting-and-diagnostic-information-

I dug into the Jenkins code (https://github.com/jenkinsci/github-plugin/blob/master/src/main/java/org/jenkinsci/plugins/github/webhook/subscriber/DefaultPushGHEventSubscriber.java#L88-L107) to figure out what wasn't matching up. You can see what it's expecting in the pipeline by going to your Jenkins instance script console (/script) and executing this:

import com.cloudbees.jenkins.GitHubRepositoryNameContributor;

for (Item job : Jenkins.getInstance().getAllItems(Item.class)) {
  print(GitHubRepositoryNameContributor.parseAssociatedNames(job))
}

That will loop through all your jobs and output the values for the repos that it's checking against.

Fo.
  • 176
  • 8
  • This answer helped me debug a very tricky webhook issue we were seeing. Our Jenkinsfile was only triggering other jobs that already existed in parallel, so we didn't have a repo that was cloned in the Jenkinsfile. That prevented the webhook from triggering the job even though we had the Github Project defined in job definition. We resolved this by cloning the repo in the Jenkinsfile – Brandon Feb 05 '18 at 17:36
  • 3rd option helped me to go a solution. I am using multiple ssh keys for my multiple github repo's. So in ~/.ssh/config file I needed to use different custom hostnames for those keys to work with github, so I was entered the same hostname on jenkins job like "git@my-application:my-organisation/my-repo.git" but this makes it mismatched with the payload webhook sends so it fails to trigger. Replace your repo url like git@github.com:your-org/your-repo.git and it will work! – spetsnaz Oct 26 '21 at 23:10