Reputation: 63
My Primary doubt is how github authentication happens in jenkins ?
Task: We have to establish connection in jenkins with github repo for "GitHub Pull Request Builder".
GitHub Auth ----> GitHub Server API URL : https://api.github.com (Why we are giving this value ? We did not give any of repository name here, So, how authentication is happening?) ----> credentials : I have given mine and tested with "connect to API", Response is: Connected to https://api.github.com as null (null) login: {{ my_user_name }}
----> But if i give my colleague credentials (which are already listed under credentials) and tested with "Connect to API" then below error has been coming.
Unable to connect to GitHub API: org.kohsuke.github.HttpException: {"message":"Requires authentication","documentation_url":"https://docs.github.com/rest/reference/users#get-the-authenticated-user"
GitHub Pull Request Builder
GitHub Auth
GitHub Server API URL https://api.github.com
Help for feature: GitHub Server API URL
Jenkins URL override
Help for feature: Jenkins URL override
Shared secret
••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
Help for feature: Shared secret
Credentials user_name/****** (github user)
Add
Help for feature: Credentials
Test basic connection to GitHub
Error:
Connect to API
Unable to connect to GitHub API: org.kohsuke.github.HttpException: {"message":"Requiresauthentication","documentation_url":"https://docs.github.com/rest/reference/users#get-the-authenticated-user"}
Could someone please help on this ?
Upvotes: 2
Views: 12229
Reputation: 5
In my case here in 2023, I tried following @Pingger Shikkoken's answer, though unfortunately it didnt' work.
What solved it for me was going to "Manage Jenkins -> Configure System -> Github" and just adding a new Github Server with the same settings (my API token was already up to date).
Hope this helps someone.
Upvotes: 0
Reputation: 416
I found out, how you do it. Basically Jenkins doesn't like different access tokens in global and Job specific Authentication.
Upvotes: 8
Reputation: 165
Don't use your username and password. It doesn't work. Use a Personal access token from your Github account and use it as a secret text credential with Jenkins.
Upvotes: 0
Reputation: 389
While connecting to github, you need to give credentials. For GitHub Pull Request Builder
, you need to use access token for setting up credentials for a given Github Server API Url. Authentication is done based on your access token.
When you are creating a job, at that time you are required to give your github url
. A job will be created for that particular github repository.
You can read more here.
Upvotes: -1