Integration Jira Cloud with Jenkins - jenkins

I want to integrate Jenkins with JIRA Cloud.
I want Jenkins to start build job when i'm updating Issue Status in JIRA.
example: when the issue in jira is going from status IN PROGRESS to DEV COMPLETED, I want Jenkis to start a build.
regards, Maja

Usually the flow is a little bit different.
After you done with the development you should add JIRA ticket number in commit.
Then create pull request (if you use Git as VCS) and merge it to main branch.
Git server will trigger build on the Jenkins side (you should find Jenkins plugin for your case).
After build is done there Jenkins can send update status to Jira (via Jenkins JIRA plugin
There are some variations. For example you want to allow merge only when build on Jenkins was successful. In this case JIRA update should be performed by Git service.

Thank you for your fast response, but we got different situation than the given answer. I will try to explain clearly.
1. we got Jira on cloud that successfully communicate with Gitlab. (there is a build in jenkins after commit in Jira)
2. and we got one test Jenkins on our local machine
Jira is configured in Jenkins and we got all needed plugins in Jenkins.
Now we want, with every changed status on the issue in Jira (from IN PROGRESS to DEV COMPLETED), Jenkins to make an automatic build on the job.
Additionaly, Is there any Jenkins Plugin for Jira CLOUD that could help us?

At this time, there is no Jenkins plugin / add-on for JIRA cloud, even though it is in high demand. It is rumored there may be one coming out in November / December 2017 as a beta.
If you are using Bitbucket, I'd recommend checking out Pipelines. Or, take a look at Bamboo or TeamCity as these tools integrate directly with JIRA Software Cloud.

Related

Jira and GitLab webhook! How to integrate?

How can i integrate Jira and Gitlab and status will change on request!
Git commit -> ED-1511 #AutomationState Running
Jira ticket (ED-1511) - >> will change AutomationState on Running
I don't think that you can do this with the out of the box functionality of Jira and Gitlab.
From the structure of your commit message it looks like you are trying to use the smart commits functionality in Jira. Smart commits only allow you to perform three actions:
Log time
Comment on an issue
Transition an issue to a new workflow state
This is not something you can do with smart commits. In addition the current Jira Gitlab integration doesn't seem to support smart commits.
If you wanted to build this functionality you could probably build something yourself that:
Listens for Gitlab webhooks
On receipt of a Gitlab webhook calls the Jira REST api to modify the issue
If I understand your question correctly, the GitLab integration with JIRA described here should do what you want. I only recently set this up with our JIRA cloud instance and GitLab running in an AWS instance, and I haven't tried to integrate transitioning JIRA tickets from Git commit messages. However, the documentation seems to indicate that it is possible.

Can Jenkins used with python project?

I'm developing a web application using python django. I want a CI service which can automatically pull the latest code from my github and run some test then deploy. I'm not familiar with CI, after searching for a while I found Jenkins seems to be a good solution. Can Jenkins be used for this?
Jenkins can be used with any project.
Regarding pulling the latest code, add the Jenkins GitHub plugin in order to be able to check "Build when a change is pushed to GitHub" under "Build Triggers".
That will launch your job on any new pushed commit on the GitHub repo.
From there, a Jenkins job can execute any command that you would do in command-line, provided the agent on which said job will be scheduled and executed has the necessary tools in its PATH (here python)
An alternative (which does not involved Jenkins) is to setup a webhook and a listener on your server which will detect a "push event" sent by said webhook.

How to trigger jenkins build upon bitbucket pull request merged

I looked at all other related questions and answers, didn't find anything solid, hence I'm opening a new question to look for your kind help, I've been working on this the whole day, any help I can get would be highly appreciated.
Here's my environment:
self-hosted jenkins server (Jenkins ver. 1.651.3) with git and bitbucket plugin installed.
https://bitbucket.org (I do not have a self-hosted bitbucket server)
What I want to do: to trigger jenkins build upon pull request got merged from feature branch to master branch.
Different setting combinations which I had tried:
jenkins: 'Build when a change is pushed to BitBucket' checked.
bitbucket: web hooks trigger: 'Repository push' checked.
Result: build was triggered successfully upon commit to master branch, but that's not what I want, but at least I know the communication between my jenkins server and bitbucket is fine.
jenkins: 'Build when a change is pushed to BitBucket' checked.
bitbucket: web hooks trigger: 'Repository push' checked, and Pull Request - 'Merged' checked.
Result: jenkins does not respond to the pull request merged action. I assumed it would work since I had the Pull Requst - 'Merged' checked in the web hooks trigger setting, and I did see the request was sent by bitbucket to my jenkins server, and it got 200 status code back from my jenkins server, but still, nothing happens.
jenkins: 'Build when a change is pushed to BitBucket' checked. And besides that, I installed another plugin called bitbucket-pullrequest-builder-plugin, and configured it according to the instruction.
bitbucket: web hooks trigger: 'Repository push' checked, and Pull Request - 'Merged' checked.
Result: with the help of bitbucket-pullrequest-builder-plugin, the build was indeed triggered upon pull request created. But the jenkins server polls the bitbucket repository constantly, and I didn't find a way to stop that, no way to trigger build ONLY upon merge neither...
I heard there's people says that you'll need to install a post-hook plugin on the bitbucket server in order to do what I want to do, but the thing is I dont host the bitbucket...
Based on some research you can have a few options as of today Nov 12 of 2017:
Use the generic post webhooks plugin that supports pull request trigger. And from jenkins pick it up with the generic webhooks plugin, then maybe do a secondary trigger from jenkins.
Upgrade the bitbucket server and webhooks to jenkins plugin. The server 4.13 does not work well with later webhooks to jenkins plugin. A paid version of the plugin probably is your best choice.
Or try bamboo that comes with the "plan banches" feature.
When you configure GIT - push, commit... etc hooks, be sure to check the JENKINS git selection, and set the BRANCH to check for (** specifies all branches) and most importantly,
USE localtunnel.me or similar to set your JENKINS online or it won't work.

GitLab and Jenkins integration

I've read the differences between Gitlab Community and Enterprise in this page: https://about.gitlab.com/features/
Based on that page I understand the integration with Jenkins is only available in the enterprise version. However, I've seen that using web hooks I can trigger builds in Jenkins when a push happens in Gitlab.
So my question is which is the difference between community and enterprise regarding the integration with jenkins?
On the merge request page, there is a state widget that shows the status of tests for that particular merge request, and on your project home page, there is test status badging. These two UI elements only show up if you enable a 'ci service' on the project. In community you can turn it on with Gitlab CI. In enterprise you can set it up to work with jenkins.
Based on that page I understand the integration with Jenkins is only
available in the enterprise version.
This is no longer true, the Jenkins GitLab Plugin (from a 3rd party) works to hook Jenkins into GitLab as a CI provider.
The wiki page has an example setup with lots of details you'll need to get it working.
This will give per-commit build/test status indicators in GitLab and also hook into the Merge Request system (both in the local repo and when merge requests come from forked repos).
You can also integrate GitLab with Jenkins using the Generic Webhook Trigger Plugin.
An example of integrating with that plugin, to perform static code analysis on merge requests, is available in the Violation Comments to GitLab Plugin wiki page.

Github Jenkins plugin with Github Enterprise

I have a Jenkins server with the following github plugins:
github-api
github
github-pull-request
I want to trigger a build after a merge (from a PR). This is because I have some build chains that I don't execute when building a PR so after a merge I need to create new deployment packages.
In the enterprise github there doesn't seem to be the same interface (as regular github) for webhooks I don't seem to be able define what events the github plugin (webhook) should listen for so I think its just the default 'push' event. Is this done somewhere else or is it a limitation of the enterprise version?
UPDATE
I have the github plugin working now but its builds for every push if I check the box. This disucssion https://groups.google.com/forum/#!topic/jenkinsci-users/gew5gWVDxw8 suggests that I should be able to use the git scm and github plugin together. Github plugin will register a change, scm plugin will poll server to determine if this change was tho the watched branch. I also tried this suggestion How can I make Jenkins CI with git trigger on pushes to master?
When I try and configure this no branch is ever built!
At least for me it's not exactly clear from your question what you actually exactly want.
It sounds like you only want builds to be triggered if there are some new commits on github on a specific branch.
If this is all you're looking for, you can just setup a webhook (Jenkins (Github Plugin)).
In you Jenkins job, just specify the branch you're tracking (Branches to build).
Assuming you setup github's hoock to jenkins correctly, this should trigger your build job on each commit on github enterprise.
If your hook doesn't seem to work: To check if and what your github server actually would send to your jenkins server, you can temporarily replace the url to your jenkins server in github's webhook with something like requestb.in (this will let you inspect github's hook payload)

Resources