Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web hook not triggering build #184

Closed
strawd opened this issue Jan 7, 2017 · 22 comments
Closed

Web hook not triggering build #184

strawd opened this issue Jan 7, 2017 · 22 comments
Labels

Comments

@strawd
Copy link

strawd commented Jan 7, 2017

I have set up a job to trigger on "Pull Request Opened" and "Commit changed", and web hooks are being sent from GitHub Enterprise, but the job does not trigger automatically and the GitHub PR Polling Log does not update after the hook is sent.

Further info:

  • Web hook triggering works just fine when I use the GitHub plugin only and the "Build when a change is pushed to GitHub" option from that plugin (which I leave unchecked when attempting to get the GitHub integration plugin to work).
  • Security is set to "Grant READ permissions for /github-webhook" and I'm using a personal access token with the "repo:status" permission for accessing the GitHub repo.
  • API URL is set to "https://<GitHub Enterprise address>/api/v3"
  • When the web hook triggers I see "Received POST for <project URL>" in the Jenkins system log
  • If I manually trigger the PR check using the "Run GH PR Trigger" button, it works as desired and all out-of-date PRs are built
  • refspec is set to "+refs/pull/${GITHUB_PR_NUMBER}/merge:refs/remotes/origin-pull/pull/${GITHUB_PR_NUMBER}/merge"
  • Branch specifier is set to "origin-pull/pull/${GITHUB_PR_NUMBER}/merge"
  • I'm using the "Hooks with Persisted Data" Trigger Mode
  • I noticed that the project URL in the system log has no trailing slash, but the project URL in the job configuration does have a trailing slash. If I try to remove the trailing slash in the job config (or change it to something else and then back), it once again has a trailing slash when I come back to the config. I'm not sure if that matters for matching the URL in the hook.

Any help you could provide would be appreciated.

@strawd
Copy link
Author

strawd commented Jan 9, 2017

I tried upgrading Jenkins from 2.7.1 to 2.32.1, but that appears to have made no difference. The plugins are all on their latest versions:

  • GitHub: 1.25.0
  • GitHub Authentication: 0,25
  • Git: 3.0.1
  • GitHub API: 1.82
  • GitHub Integration: 0.1.0-rc18

@KostyaSha
Copy link
Owner

and I'm using a personal access token with the "repo:status" permission for accessing the GitHub repo.

I guess you missing admin repo_hooks permission. Trailing slash is sensitive details here jenkinsci/github-plugin#152

@KostyaSha
Copy link
Owner

So provide permissions for token and it will register right hook urls.

@strawd
Copy link
Author

strawd commented Jan 9, 2017

Thanks for getting back to me so quickly. I had tried managing the hooks from Jenkins before with little success. I just tried again with the same result by doing the following:

  1. Add "admin:repo_hook" permission to the access token in GHE
  2. In Jenkins, under GitHub > GitHub Servers, check "Manage hooks"
  3. Click "Advanced"
  4. Click "Re-register hooks for all jobs"

Saw the following in the system log:

Jan 09, 2017 11:50:35 AM INFO org.jenkinsci.plugins.github.config.GitHubPluginConfig doReRegister
Called registerHooks() for 1 items
Jan 09, 2017 11:50:35 AM INFO org.jenkinsci.plugins.github.webhook.WebhookManager$1 run
GitHub webhooks activated for job [Redacted] with [GitHubRepositoryName[host=[Redacted],username=[Redacted],repository=[Redacted]]] (events: [ISSUE_COMMENT, PULL_REQUEST])
Jan 09, 2017 11:50:36 AM WARNING org.jenkinsci.plugins.github.webhook.WebhookManager$2 applyNullSafe
Failed to add GitHub webhook for GitHubRepositoryName[host=[Redacted],username=[Redacted],repository=[Redacted]]
java.lang.NullPointerException: There is no credentials with admin access to manage hooks on GitHubRepositoryName[host=[Redacted],username=[Redacted],repository=[Redacted]]
	at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:231)
        ...

@KostyaSha
Copy link
Owner

KostyaSha commented Jan 9, 2017

Failed to add GitHub webhook for GitHubRepositoryName[host=[Redacted],username=[Redacted],repository=[Redacted]]
java.lang.NullPointerException: There is no credentials with admin access to manage hooks on GitHubRepositoryName[host=[Redacted],username=[Redacted],repository=[Redacted]]

That what i said :) Also please check that your automation user accepted invite to repository.

@KostyaSha
Copy link
Owner

Simply give more permissions for token and try again.

@strawd
Copy link
Author

strawd commented Jan 9, 2017

I had tried previously with my own (owner) account and it had still failed, as well as an access token with all permissions. Which credentials config exactly in Jenkins needs to be set to the right value? I've been assuming it's the "Credentials" field under "GitHub Server"

@strawd
Copy link
Author

strawd commented Jan 9, 2017

Anyway, giving up on the auto-manage hooks feature, it looks like I was able to get this to work by setting up a web hook manually. I'm currently not using the Jenkins (GitHub plugin) service, but a web hook configured with events "issue_comment" and "pull_request", and a URL ending with a trailing slash.

Thanks for your help!

@strawd strawd closed this as completed Jan 9, 2017
@KostyaSha
Copy link
Owner

Which credentials config exactly in Jenkins needs to be set to the right value? I've been assuming it's the "Credentials" field under "GitHub Server"

Yes, github server configuration in global settings. PR/branch trigger uses this global connection from github-plugin API. When you reconfigure job it tries register hook. When there is no enough permissions, then it may fail.

@hila3000
Copy link

hila3000 commented Feb 9, 2019

I have the same error-
Failed to add GitHub webhook for GitHubRepositoryName[host=github.com,username=me,repository=myrepo.git]
java.lang.NullPointerException: There is no credentials with admin access to manage hooks on GitHubRepositoryName[host=github.com,username=me,repository=myrepo.git]

defined manage hooks checkbox, in system configuration, tested connection with the access token and it's ok
AND I gave the access token ALL the permissions available! so which credentials is it missing?

@KostyaSha
Copy link
Owner

Do you have trailing slash somewhere in addresses?

@hila3000
Copy link

hila3000 commented Feb 9, 2019

you mean in the jenkins URL in "configure system"? yes, it's like this- http://jenkinsurl:8080/
but even if I delete the slash and save, returning to the configure system screen shows the slash is back.

@hila3000
Copy link

hila3000 commented Feb 9, 2019

I had a trailing slash in the git repo in the job itself.
Now it works.
Thanks a lot Kostya :)

@KostyaSha
Copy link
Owner

This is really annoying, will check what could be done. Sounds like slash is a culprit of a lot of reports.

@hila3000
Copy link

hila3000 commented Feb 9, 2019

I don't mind the slash, I mind the error in log - It had nothing to do with the existence of the slash.. without you, I would have never guessed it's related to the slash. So probably also should refine the error messages.

@KostyaSha
Copy link
Owner

One user found this, i also didn't know what's wrong :)

@hila3000
Copy link

hila3000 commented Feb 9, 2019

As long as we're spreading the love :)

@KostyaSha
Copy link
Owner

@hila3000 could you write example of bad url that you had in your job settings?

@hila3000
Copy link

hila3000 commented Feb 9, 2019

@KostyaSha
Copy link
Owner

Github UI suggests clone url without slash. Where did you get this trailing slash?

@KostyaSha
Copy link
Owner

Upstream fix jenkinsci/github-plugin#206

@hila3000
Copy link

hila3000 commented Feb 9, 2019

I have no idea.. wasn't intentionally though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants