x-yuri
x-yuri

Reputation: 18963

How to make Jenkins automatically add webhook for Pipeline job?

I have added credentials for Jenkins to be able to add a webhook. For that I did the following:

  1. Generated personal access token on GitHub with repo and admin:repo_hook scopes.
  2. Added Secret text credentials with corresponding token.
  3. Added GitHub Server with credentials from the previous step in Manage Jenkins > Configure System.

But then when I create Pipeline job, I see in the system log:

GitHub webhooks activated for job p1 with [] (events: [PUSH])

With Freestyle project I get:

GitHub webhooks activated for job fsp1 with [GitHubRepositoryName[host=github.com,username=user,repository=repo]] (events: [PUSH])
PING webhook received from repo <https://github.com/user/repo>!

For Freestyle project I did the following:

  1. On Source Code Management tab chose Git, specified repository URL and credentials (Username with password).
  2. Checked GitHub hook trigger for GITScm polling.

For Pipeline job:

  1. Checked GitHub project and specified repository URL.
  2. Checked GitHub hook trigger for GITScm polling.

What am I missing?

Upvotes: 5

Views: 2611

Answers (2)

Piyush Sinha
Piyush Sinha

Reputation: 121

To make it add the webhook (after creating a pipeline):

  • run the pipeline once manually
  • reregister the webhooks (Manage Jenkins > Configure System > GitHub plugin > Advanced (with a pencil mark) > Reregister hooks for all jobs)

It is a known issue. You can look it up here: https://issues.jenkins.io/browse/JENKINS-37217

Upvotes: 4

keyolk
keyolk

Reputation: 135

I have similar issue. I dont know why but It become well after run the job from blueocean.

Upvotes: 0

Related Questions