Github Enterprise - Plugin for Jenkins - github

I'm trying to get the post-commit hooks for github enterprise to talk to our internal jenkins server. Been trying for the last several hours and haven't been able to get it working.
What I was able to do is get the github enterprise webhook with url:
http://192.168.10.123:8080/job/Github%20Build%20Test/build
working to kick off a build.
I'm not able to authenticate with github enterprise using either the basic authentication or oauth2 authentication tokens.
Also with manual setup it doesn't seem to work either. Any ideas / help?

I think you may need to wait for v1.41 of the Jenkins GitHub API plugin
See this pull request

Related

GitHub webhook repo is unable to trigger jenkins pipeline

Our Company used to self-host GitLab for source-code management and configured webhook on gitlab to trigger all the project pipelines on jenkins. Initially, the gitlab url was 'https://git.fulcrumdigital.com' and later for an upgraded version, they changed url to 'https://autobuild.fulcrumdigital.com'
Recently, we migrated to 'github.com' and created an organization. The source codes for various projects are found under this organization, which is private. Now, when I try to configure webhooks for these projects, I see that they deliver as intended to jenkins, but jenkins doesn't trigger the respective project's build. Instead, it gives out a message as shown below.
jenkins-github webhook error
I don't find any info regarding this webhook on global configuration page.
Here is a snapshot of jenkins logs
jenkins logs
I don't face this webhook issue for newly created pipeline-projects on jenkins. I face this issue for older pipeline-projects that already had their webhook configured earlier for gitlab.
Help me to resolve this issue and make jenkins trigger build from github webhook for older pipeline-projects.
Did you try force regenerating the webhooks?
Go to Manage Jenkins > Configure System > GitHub plugin > Advance > Re-registers hooks for all jobs.
I had this problem myself. The first thing you want to do is go to Manage Jenkins -> Configure System scroll down to the GitHub section and click on "Advanced". You will see this:
It's important to have access to your Jenkins log (I'm running Jenkins with Docker). When I clicked on Re-register hooks for all jobs, I got the following error:
In my case, the error mentioned something with my access token. So, I checked my Github personal access token and it turned out, I need to turn on Read and Write for Webhook:
Now, go back to Jenkins and click on Re-register hooks for all jobs again, and on the next push, the build was automatically triggered.

Jenkins github plugin returns error 400 "Hook should contain event type"

At my company we have a Github Enterprise instance keeping all of our source in line, and Jenkins servers to do continuous integration. I'm using the Jenkins github plugin on Jenkins, and installing a service on Github to call MYJENKINS/github-webhook.
I would see the POSTs arriving from github on the jenkins server, but nothing would happen. The access log reports a 400 error being returned to github.
To find out what was being returned, I put tcpdump on the port. I now see that Jenkins is returning "Error 400 Hook should contain event type". It returns that for all repository events.
I can probably capture the github POST payload with tcpdump, but haven't done that yet.
My only guess at the moment is that our Github Enterprise installation is an earlier version than what is expected by the Jenkins github plug-in.
Update: As an experiment, on Github, I changed the call from a Service ("Jenkins github plugin") to a Webhook, but using the same URL MY_JENKINS/github-webhook/. THAT succeeds, is parsed successfully by the github plugin, and triggers the jobs that are watching a project/branch.
Github Enterprise should have webhook functionality built-in, so I'm a little unsure what you mean when you say you're installing a service on Github.
You can set up new webhooks by going to the following tab:
https://github-enterprise.com/my-org/myrepo >> Settings >> Webhooks & services
Here is a screenshot:
The other place to check is the settings in Jenkins, to make sure that it is set up to work with Github.
Jenkins >> Manage Jenkins >> Configure System >> Find: GitHub Plugin Configuration
In here, you need to provide your credentials for Github as well as the Github api url:
https://<github-enterprise.com>/api/v3/
(You might be able to leave the 'Custom Github API URL' unchecked, but I haven't had good success with that.)
Here is a screenshot:
The 'Credentials' would be an access token from Github.
Github >> Personal settings >> Personal access tokens
It's been a while since I've done setup like this, so feel free to correct me if I'm wrong about anything.

Create request in JIRA from Jenkins

I want to use the REST API of JIRA to create issue. I found the following:
https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis
The Jenkins ad JIRA are installed on windows so I cant use curl.
I am able to make http request from browser and create issues in JIRA. But not sure how to do same from Jenkins. Jenkins has a HTTP request plugin, but it doesn't have a data fields to make a proper POST call.
Please suggest some alternatives or a way to fix the above scenarios.
Jenkins has https://wiki.jenkins-ci.org/display/JENKINS/JIRA+Plugin which can handle issue creating:

Is it possible to use git hub login for local sonar application?

Is it possible to use git hub login for sonar application?
Just like Jenkins can be configured.
if possible please provide steps to configure.
A SonarQube GitHub Authentication Plugin has been created since the accepted answer was written.
For SONAR you need not connect with GITHUB directly, use jenkins to get the latest code to your agent and in the smae job invoke your sonar analysis - either using runner or maven goals, it should work fine
There is currently no plugin allowing the delegation of authentication to GitHub

How to validate GitHub is communicating with OpenShift cartridge running Jenkins?

I have a GitHub hook for a new check-in, but it is not being received by Jenkins (running on a RedHat OpenShift cartridge).
Setup
RedHat OpenShift cartridge running Jenkins
Jenkins plugins in-play
GitHub plugin v1.8
Github Authentication plugin v0.14
Jenkins GIT client plugin v1.4.5
Jenkins GIT plugin v2.0
Public GitHub repository
Debugging
I have narrowed it down specifically to GitHub communicating with OpenShift, but am unsure how to troubleshoot any further, or resolve the issue. To narrow it down, I performed the following steps:
Configured one of each of the following types of Service Hooks in GitHub and captured the results in RequestBin
WebHook URL
Jenkins GitHub Plugin
Jenkins Git Plugin
I then ran Test Hook from GitHub
I took the resultant headers and payload from each RequestBin and manually created a POST request in Fiddler, pointing to the webhook endpoint
I saw some action on Jenkins by logging against com.cloudbees.jenkins.GitHubWebHook
However, the Test Hook from GitHub and checking into the repository never reached the server, at least not as evidenced by the logs.
I believe I have narrowed it down to an SSL issue. GitHub will not post the webhook to an OpenShift configured Jenkins cartridge, because it only responds to SSL/HTTPS. I am not sure of the specifics of how the canned Jenkins cartridge is configured, or how to change whether or not it uses SSL.
It is possible to change whether or not the OpenShift cartridge uses SSL, but I did not want to spend the time to get into it. The solution is to create your own cartridge definition, where you can specify all the settings, specifically which endpoints get created. Here is the OpenShift reference to generate the proper endpoints in case anyone wants to go that route.
I believe I have narrowed it down to an SSL issue. GitHub will not post the webhook to an OpenShift configured Jenkins cartridge, because it only responds to SSL/HTTPS. I am not sure of the specifics of how the canned Jenkins cartridge is configured, or how to change whether or not it uses SSL.
It is possible to change whether or not the OpenShift cartridge uses SSL, but I did not want to spend the time to get into it. The solution is to create your own cartridge definition, where you can specify all the settings, specifically which endpoints get created. Here is the OpenShift reference to generate the proper endpoints in case anyone wants to go that route.