Workflow action not executed in Jira Issue Updater plugin - jenkins

So currently I am trying to progress my JIRA workflow with the Jira Issue Updater plugin in Jenkins. Attached are my config screenshot and my workflow. However i get this error when I execute a commit triggered build.
JIRA Update Results Recorder
Unable to connect to REST service
java.io.IOException: Server returned HTTP response code: 400 for URL: http://*******:9055/rest/api/2/search?jqlFinished: SUCCESS
This does not have any effect on my Jira workflow.
Thanks for the help in advance and let me know if more information is needed.
Hadi
EDIT: I got a 404 meaning the JQL is incorrect, but when I try to use that in incognito mode I get an empty string, However, if i am locally logged in, I get all issues in xml format.
Workflow
Jenkins Jira Config

I ended up using the JIRA plugin instead.
I used Progress JIRA Issues by workflow action step after build successful phase.
Attaching a screenshot of the configuration.
I am still trying to figure how to pull the issue number from the commit message for this action.
JIRA PLUGIN CONFIG
This is a following question and answer if anybody else gets stuck:
How can I get JIRA issue number from a commit message in Jenkins

Related

Jenkins and Bitbucket.org webhooks 404/200 error

I've been struggling with a webhook configuration for quite some time now and would to reach to you all for some help.
I have configured a webhook in my bitbucket repo to push to jenkins so that jenkins can receive the notification and begin a build of the project.
At first we had some networking issues, which have been corrected. i then started to get a 403 error (crumb issue). After some research i was able to add my login and API token to the webhook url and now getting a 404 error. The url cannot be found.
my webhook url looks something like this.
https://username:apitokenhere#serverwherejenkinsis.com:8080/projectname/bitbucket-hook/
404 error
But when i use the webhook URL
https://username:apitokenhere#serverwherejenkinsis.com:8080/bitbucket-hook/
I get a 200 message
Is there a config file that i need to change within jenkins to "listen" to that URL? my project is build properly with the option of "bitbucket webhook trigger" selected. I have also selected "Poll SCM" where i found some sites suggesting this option. But when i push a commit on my repo, i dont get any feedback from jenkins.
Any help is greatly appreciated.
I wanted to post an update as i have figured out what my problem was.
the webhook url did not need my credentials to end the bread crumb error. in fact the hook url is pretty basic.
https://serverwherejenkinsis.com:8080/bitbucket-hook/
I did not need to have the project name in the URL. ALSO, the project name in jenkins needed to match exactly what the project name is within bitbucket.

Publish the Screenshot/PDF of SonarQube Analysis Result from Jenkins to Confluence

I have a Jenkins job that will invoke SonarQube analysis on code pulled from a Bitbucket repository whenever there is any changes on the Bitbucket repository. At the moment, I was able to use the Confluence Publisher plugin to publish the URL of the build job to Confluence as a comment.
I was wondering if there is any way I could use Jenkins to screenshot the SonarQube analysis report (like in SonarQube web UI) and publish it directly to Confluence? (So that the user does not need to use the URL to go to the specific Jenkins build job, and then get the SonarQube analysis report URL, and navigate to the page to view the report)
Thank you.
Instead of using a screenshot, you can send a curl request from Jenkins to SonarQube REST API (5.3 and above) to get the project status from the quality gate after the code has been uploaded and analysed. The endpoint you'd likely want to use is: /api/qualitygates/project_status?prjectKey=<projectKey>&branch=<branch>
According to the web API docs:
Get the quality gate status of a project or a Compute Engine task.
Either 'analysisId', 'projectId' or 'projectKey' must be provided
The different statuses returned are: OK, WARN, ERROR, NONE. The NONE status is returned when there is no quality gate associated with the analysis.
Returns an HTTP code 404 if the analysis associated with the task is not found or does not exist.
Requires one of the following permissions:
'Administer System'
'Administer' rights on the specified project
'Browse' on the specified project
Once you have these results available, you can create a Jenkins user in Confluence and have Jenkins send a POST request to create a page or a comment with the results obtained.

Prevent SonarQube from failing Pull Request checks

I've set up an automatic "pull request check" via jenkins/github/sonarqube integration.
The workflow is as follows:
Github pull request created by user → Github Webhook triggers, and calls Jenkins API to execute sonarqube scanner → reports to sonarqube server → sonarqube server calls github API(create commit statuses : ref https://developer.github.com/v3/repos/statuses/) and posts a comment about the PR.
The issue is that it marks the PR as check failed just because it didn't pass its code health checks. The build passed, but the code is "dirty" - and that causes the PR to be marked as unacceptable. I'd like to find a way to prevent code quality checks from appearing as an actual status of the commit, and only allow commenting.
Additional images to provide some context:
SonarQube uses a techuser account token to post its analysis summary as a comment on the PR thread. (Sorry for the black boxes, corporate stuff..)
This functionality is everything we need, nothing more.
However... the plugin does one more thing, which is marking the commit as a failure. Note that we're already using something else to check for actual build failures. Although it didn't fail, sonarqube marking the commit as failure because of code quality makes the whole commit display as a failure. I'd like to prevent sonarqube from setting branch check statuses, while letting it comment on the issue. I couldn't find an option for anything like that neither in jenkins plugin configuration nor sonarqube admin page nor sonarqube scanner script documentation.
Thanks in advance.
What you want to achieve is currently not possible when using the SonarQube GitHub plugin, since this behaviour is hardcoded in the plugin and there is no configuration option to customize this.
In upcoming versions of SonarQube and SonarCloud, pull request will have a built-in support and the behaviour will be the following:
The status will be red if there is at least an open issue on the PR analyzed by SonarQube/SonarCloud
Teams will have the ability to mark those issues as "Confirmed" in SonarQube/SonarCloud (to acknowledge that they accept this technical debt), in which case the status will be automatically turned to green in GitHub

Jira Jenkins Integration | Issue Id

I was trying to get an SVN, Jenkins and Jira integration going. The aim being to change the status of a ticket/issue to 'Fixed' when it is referred to in an SCM comment. The process being orchestrated by Jenkins. The flow details are
developer puts in the Jira ticket number (MDP-1) on an SVN commit
message.
The build is kicked off in JenkinsJenkins (using the Jira
plugin) can figure out the Jira ticket referred to it in the SVN
commit message. It updates the Jira ticket by putting in a Jira
comment.
So far, this is working great!
Now, I also want to change
the status of the ticket to 'fixed'. I am trying to use the Jenkins
step (Progress jenkins issues by workflow action). I am unable to
access the Jira issue ID/ticket number.
I know, under the hood, the Jira plugin has access to this. Thats why it is able to put in a comment to the Jira ticket in the first case. Question is how/what variable do I use to get access to this Jira ticket# in Jenkins
I actually got this working with another Jenkins plugin (https://wiki.jenkins-ci.org/display/JENKINS/Jira-Ext+Plugin).
This captures the Jira issue_id(s) captured in the SCM commit message and exposes them in an environment variable.
Just what I was looking for!

How to trigger a Jenkins job from a status change in Jira

I have been looking for a while now for a way to trigger a Jenkins job from the status or a ticket/story in Jira changing status. To give a more detailed example when my team moves a ticket to the 'ready for test' column we would like to be able to trigger a sanity test pack in Jenkins, the ideal situation would then be that we are able to post the results (generated as a html) as a comment on the ticket within Jira. Failing that we would like to be able to publish the results as simply pass/fail.
I have recently been looking at the Jenkins Jira plugin but this does not seem to have the functionality to work both ways, in other words it can post results after a job has run but you cannot trigger the job from a change of status in Jira. Is there any such plugin available or is it something that we will need to create ourselves?
Cheers in advance
So, basicly there are webhooks in jira (https://developer.atlassian.com/jiradev/jira-architecture/webhooks). With it you can configure it to trigger specific url on issue status change. The specific url should be jenkins API, for example for triggering a build you should call an external url like (if you are building with parameters): http://server/job/myjob/buildWithParameters?token=TOKEN&PARAMETER=Value
Some more info https://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API
I have written a Jenkins plugin that supports JIRA status change trigger: jira-trigger-plugin.
This plugin also injects an environment variable of JIRA_ISSUE_KEY, so you can utilise this information to publish your result back to JIRA e.g. using REST API.
Please follow as mentioned below:
GIT:
You can set the web hooks for git/ bitbucket /stash on commit which inturn should change the state of task in JIRA.
JIRA:
Once you in JIRA. define the workflow for your task.
In this particular workflow you can set a post-function where the web hook should be configured. In this configuration of webhook in events define JQL as below:
status CHANGED FROM "To Do" TO "ready to test".
In the same mention the job that needs to be fired in the URL section.
You can look through webhooks in Jira :
https://support.atlassian.com/jira-cloud-administration/docs/manage-webhooks/
You also need to add the Generic Webhook Trigger plugin to your Jenkins :
https://plugins.jenkins.io/generic-webhook-trigger/
You can find here an example on how to use the Generic Webhook Trigger plugin with Bitbucket Github and Gitlab. https://github.com/jenkinsci/generic-webhook-trigger-plugin/tree/master/src/test/resources/org/jenkinsci/plugins/gwt/bdd
It involved multiple steps
If you are using Git/Stash/BitBucket (which i implemented),
You can simply
configure the commit hooks in your Stash/Bitbucket
Attach events to your JIRA workflow
Jenkins JOB - post build events - configure Notify
Stash plugin Set the Poll SCM
That's it

Resources