Jenkins Log Recorders

My Jenkins job was set to trigger a build automatically from a simple GitHub webhook, but the job didn’t build when code changes were pushed to GitHub. Was the problem in Jenkins, GitHub, or something else? I investigated using Jenkins log recorders.

To eliminate GitHub as the possible obstacle, I added relevant loggers¹ to Jenkins’ default log recorders:

  • com.cloudbees.jenkins.GitHubWebHook
  • org.jenkinsci.plugins.github.webhook.*
  • org.jenkinsci.plugins.github.admin.GitHubHookRegisterProblemMonitor

¹ These loggers are listed in B.5 Dedicated Logger among the troubleshooting options in GitHub: Webhook Troubleshooting. (Note that the GitHub Plugin wiki page lists a slightly different set of loggers.)

The steps below outline the procedure.

  1. Open the Jenkins Log page (screenshot below): Jenkins home page > Manage Jenkins > System Log
    (Direct URL is like this: http://<jenkins-url>/log/)System Log page
  2. Click Add new log recorder. This opens a new form with a text field: enter a unique name like “GitHub Logs”, then click OK to open the form below.Log recorder
  3. Next to Loggers, click Add: enter a logger string and choose a level or leave the default (ALL). Repeat for the remaining loggers.
  4. Click Save.

Now any GitHub webhook invocations that point to this Jenkins should add entries to its Log page, as in the sample below.

 

Apr 13, 2018 11:12:57 AM FINE org.jenkinsci.plugins.github.webhook.GHEventHeader$PayloadHandler parse
Header X-GitHub-Event -> push
Apr 13, 2018 11:12:57 AM FINEST org.jenkinsci.plugins.github.webhook.GHEventPayload$PayloadHandler parse
Payload {"ref":"refs/heads/azure-pipeline","before":"8452990cfb60bece5da4cc34a8d122729f4d976e","after":"963bbc57d3...
Apr 13, 2018 11:12:57 AM INFO org.jenkinsci.plugins.github.webhook.subscriber.DefaultPushGHEventSubscriber onEvent
Received POST for https://github.com/groverboy/game-of-life-azure-pipeline
Apr 13, 2018 11:12:57 AM FINE org.jenkinsci.plugins.github.webhook.subscriber.DefaultPushGHEventSubscriber$1 run
Considering to poke Web Team » free-webhook-testr
Apr 13, 2018 11:12:57 AM FINE org.jenkinsci.plugins.github.webhook.subscriber.DefaultPushGHEventSubscriber$1 run
Skipped Web Team » free-webhook-testr because it doesn't have a matching repository.
Apr 13, 2018 11:12:57 AM FINE org.jenkinsci.plugins.github.webhook.subscriber.DefaultPushGHEventSubscriber$1 run
Considering to poke Web Team » game-of-life-jenkinsfile-github-trigger
Apr 13, 2018 11:12:57 AM FINE org.jenkinsci.plugins.github.webhook.subscriber.DefaultPushGHEventSubscriber$1 run
Skipped Web Team » game-of-life-jenkinsfile-github-trigger because it doesn't have a matching repository.

 

These log entries confirm that the GitHub webhook works as expected for a repo at the URL specified in line 6, copied below:

 

Received POST for https://github.com/groverboy/game-of-life-azure-pipeline

 

Jenkins checks every job and triggers the ones matching this URL. The log shows that no job was triggered (all jobs were skipped), but the problem is not with my GitHub setup.

 

Summary

The log recorder framework is a powerful mechanism for digging into the behaviour of a plugin. If you need to know which loggers are available for a given plugin, start with the plugin documentation.

Leave a Comment

Scroll to Top