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

Cannot get credentials to work #398

Open
shevek opened this issue Mar 7, 2016 · 8 comments
Open

Cannot get credentials to work #398

shevek opened this issue Mar 7, 2016 · 8 comments

Comments

@shevek
Copy link

shevek commented Mar 7, 2016

The credential checks in global config all work, it can post a comment, etc but the credentials themselves don't seem to work in the job. The only reason clone works is that it's using the default ssh keys.

Jenkins 1.651, GHPRB 1.31.1

Setting status of c39b147c387db8f6f4e5ee2e1c183d90625328e0 to PENDING with url http://myhost:8080/job/myjob-pr/1/ and message: 'Build started sha1 is merged.'
FileNotFoundException means that the credentials Jenkins is using is probably wrong. Or the user account does not have write access to the repo.
java.io.FileNotFoundException: {"message":"Not Found","documentation_url":"https://developer.github.com/v3"}
    at org.kohsuke.github.Requester.handleApiError(Requester.java:527)
    at org.kohsuke.github.Requester._to(Requester.java:257)
    at org.kohsuke.github.Requester.to(Requester.java:203)
    at org.kohsuke.github.GHRepository.createCommitStatus(GHRepository.java:854)
    at org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus.createCommitStatus(GhprbSimpleStatus.java:246)
    at org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus.onBuildStart(GhprbSimpleStatus.java:168)
    at org.jenkinsci.plugins.ghprb.GhprbBuilds.onStarted(GhprbBuilds.java:130)
    at org.jenkinsci.plugins.ghprb.GhprbBuildListener.onStarted(GhprbBuildListener.java:24)
    at org.jenkinsci.plugins.ghprb.GhprbBuildListener.onStarted(GhprbBuildListener.java:17)
    at hudson.model.listeners.RunListener.fireStarted(RunListener.java:215)
    at hudson.model.Run.execute(Run.java:1734)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:410)
Caused by: java.io.FileNotFoundException: https://api.github.com/repos/MyOrg/myjob/statuses/c39b147c387db8f6f4e5ee2e1c183d90625328e0
    at sun.reflect.GeneratedConstructorAccessor64.newInstance(Unknown Source) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1677)
    at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1675)
    at java.security.AccessController.doPrivileged(Native Method) 
    at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1673)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1246)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
    at org.kohsuke.github.Requester.parse(Requester.java:483)
    at org.kohsuke.github.Requester._to(Requester.java:236)
    ... 12 more 
Caused by: java.io.FileNotFoundException: https://api.github.com/repos/MyOrg/myjob/statuses/c39b147c387db8f6f4e5ee2e1c183d90625328e0
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1626)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338)
    at org.kohsuke.github.Requester.parse(Requester.java:479)
    ... 13 more 
@shevek
Copy link
Author

shevek commented Mar 8, 2016

Note that the "Can one of the admins verify this patch" is working. It's only the build report posting which is failing.

@shevek
Copy link
Author

shevek commented Mar 8, 2016

Also, while I used credentials manager to add extra credentials to the api.github.com domain, I can't select them in the job config.

@DavidTanner
Copy link
Collaborator

Once you add credentials using the manager you need to assign that to a github url in the main config. Then it is available to use per job

@shevek
Copy link
Author

shevek commented Mar 9, 2016

In the main config, github API server URL is https://api.github.com and the credentials are github auto generated token credentials. The Test credentials button in that allows me to test those credentials, and all operations work, including posting comments. I have given the credentials a description.

In the job config, I choose a set of github API credentials - the drop down only offers me one choice, which is the description I set of my credentials in the main config. However, in practice, the job gives the error above when it tries to comment on the pull request.

I think, therefore, everything is as you ask. I can post screenshots, if that helps?

What I don't understand is how every 'Test credentials' feature works in the global config, yet doesn't work in the job.

The job is NOT using the github credentials for clone or pull, it's using the jenkins user's default ssh key, which is actually registered against a different github user, but that shouldn't matter, as that's not visible to API calls.

@shevek
Copy link
Author

shevek commented Mar 9, 2016

Changing the global config to use the login/password credentials for api.github.com instead of the token didn't make the job work.

Visiting the failing api.github.com URL in a web browser logged in as the user in question does not work, but I don't know if that's meant to work.

It all boils down to "How can Test Credentials work, but the job not work?"

@shevek
Copy link
Author

shevek commented Mar 9, 2016

It seems that moving the ssh key to the user for whom the token was created makes a difference. Can you confirm or deny the likelihood of this?

@doublesharp
Copy link

@shevek I saw a similar error creating webhooks and fixed the problem by renaming the github repository and then changing it back to the original value, it seemed to be a problem on github's side: https://issues.jenkins-ci.org/browse/JENKINS-40359

@MikhailTymchukDX
Copy link

MikhailTymchukDX commented Nov 21, 2017

Hi all,
I have the same issue like many previous ones: #129, #232, #307 and so on.

Jenkins v 2.90, GHPRB v1.39.0.

The error message:

FileNotFoundException means that the credentials Jenkins is using is probably wrong. Or the user account does not have write access to the repo.
org.kohsuke.github.GHFileNotFoundException: {"message":"Not Found","documentation_url":"https://developer.github.com/v3/repos/statuses/#create-a-status"}
	at org.kohsuke.github.Requester.handleApiError(Requester.java:686)
	at org.kohsuke.github.Requester._to(Requester.java:293)
	at org.kohsuke.github.Requester.to(Requester.java:234)
	at org.kohsuke.github.GHRepository.createCommitStatus(GHRepository.java:1075)
	at org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus.createCommitStatus(GhprbSimpleStatus.java:272)
	at org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus.onBuildStart(GhprbSimpleStatus.java:185)
	at org.jenkinsci.plugins.ghprb.GhprbBuilds.onStarted(GhprbBuilds.java:130)
	at org.jenkinsci.plugins.ghprb.GhprbBuildListener.onStarted(GhprbBuildListener.java:18)
	at hudson.model.listeners.RunListener.fireStarted(RunListener.java:240)
	at hudson.model.Run.execute(Run.java:1720)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:421)
Caused by: java.io.FileNotFoundException: https://api.github.com/repos/codecentral-examples/TestGhprb/statuses/9d82bb9a32c4d8b5dc601fb429877b68ec49d8b1
	at sun.reflect.GeneratedConstructorAccessor349.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1944)
	at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1939)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1938)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1508)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:263)
	at org.kohsuke.github.Requester.parse(Requester.java:612)
	at org.kohsuke.github.Requester.parse(Requester.java:594)
	at org.kohsuke.github.Requester._to(Requester.java:272)
	... 11 more
Caused by: java.io.FileNotFoundException: https://api.github.com/repos/codecentral-examples/TestGhprb/statuses/9d82bb9a32c4d8b5dc601fb429877b68ec49d8b1
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1890)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
	at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:347)
	at org.kohsuke.github.Requester.parse(Requester.java:602)
	... 13 more

Testing connection at Manage Jenkins -> Configure Jenkins -> GitHub Pull Request Builder works fine.
I tried credentials type with the token and with the username and password, like in #307, but no luck.

I tried to collect some logs, but there is no org.jenkinsci.plugins.ghprb logger.
There are many loggers under this namespace, which one should I use to provide you more info?

image

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

No branches or pull requests

4 participants