Create request in JIRA from Jenkins - rest

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:

Related

Service Hook of Pull Request created is not being triggered when Pull request is created through Team Services REST API

I'm trying to integrate my Visual Studio Team Services with Slack, and the first thing I tried to do was notify my Slack channel whenever a Pull request is created.
So I searched through the options, and the best fit so far was the Service Hooks available on Team Services, which integrate seamlessly with Slack, or does it?
The problem I encountered was: I use a tool that creates pull requests through the REST API, and the service hook doesn't seem to be working when I create pull requests through this method, only when using Team Services UI.
This is the Service Hook configuration.
Has anyone faced the same problem, or know any other way of notifying a pull request creation to slack?
Apparently the issue has been fixed by Microsoft, the last update of Team Services triggers the event without a problem now.

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.

Adding custom status page to Jenkins instance

I want to use the REST API that comes with Jenkins to generate a status page which shows all my projects, the environments they're currently deployed to, latest build versions etc.
Jenkins provides a nice REST API to expose this info however consuming the service is limited by cross domain restrictions. I have looked briefly at creating a CORS filter for my Jenkins instance but its overkill for what I'm trying to achieve.
Can someone tell me if its possible to modify my Jenkins WAR (instance) and add some HTML which i can then modify to call the RESTful endpoints? Ideally i want something whereby i can simply navigate to http://myjenkins/project-status and see the required information.
I assume your status page has some Javascript executing XMLHttpRequests. You could drop your status page files into $JENKINS_HOME/userContent directory on the master. This way they are served by Jenkins and should be able to access Jenkins REST APIs.

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.

Github Enterprise - Plugin for Jenkins

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