Commit 7f5e67a6 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'jira_integration_doc_update' into 'master'

Jira integration doc and reference comment changes

See merge request !310
parents 2ca2a893 8d83369f
...@@ -76,7 +76,7 @@ class JiraService < IssueTrackerService ...@@ -76,7 +76,7 @@ class JiraService < IssueTrackerService
url: resource_url(project_path(project)) url: resource_url(project_path(project))
}, },
entity: { entity: {
name: noteable_name.humanize, name: noteable_name.humanize.downcase,
url: entity_url url: entity_url
} }
} }
...@@ -127,7 +127,7 @@ class JiraService < IssueTrackerService ...@@ -127,7 +127,7 @@ class JiraService < IssueTrackerService
project_url = data[:project][:url] project_url = data[:project][:url]
message = { message = {
body: "[#{user_name}|#{user_url}] mentioned #{issue_name} in #{entity_name} of [#{project_name}|#{entity_url}]." body: "[#{user_name}|#{user_url}] mentioned this issue in [a #{entity_name} of #{project_name}|#{entity_url}]."
}.to_json }.to_json
send_message(url, message) send_message(url, message)
......
# GitLab JIRA integration # GitLab Jira integration
GitLab can be configured to interact with JIRA. GitLab can be configured to interact with Jira.
## Configuring JIRA Each project can be configured to connect to a different Jira instance, configuration is explained [here](#configuration).
If you have one Jira instance you can pre-fill the settings page with a default template. To configure the template [see external issue tracker document](external-issue-tracker.md#service-template)).
Once the project is connected to Jira, you can reference and close the issues in Jira directly from GitLab. This functionality is only available in GitLab Enterprise Edition as described in this document.
## Table of Contents
* [Referencing Jira Issues from GitLab](#referencing-jira-issues)
* [Closing Jira Issues from GitLab](#closing-jira-issues)
* [Configuration](#configuration)
### Referencing Jira Issues
When GitLab project has Jira issue tracker configured and enabled, mentioning Jira issue in GitLab will automatically add a comment in Jira issue with the link back to GitLab. This means that in comments in merge requests and commits referencing an issue, eg. `PROJECT-7`, will add a comment in Jira issue in the format:
```
USER mentioned this issue in LINK_TO_THE_MENTION
```
* `USER` A user that mentioned the issue. This is the link to the user profile in GitLab.
* `LINK_TO_THE_MENTION` Link to the origin of mention with a name of the entity where Jira issue was mentioned.
Can be commit or merge request.
![example of mentioning or closing the Jira issue](jira_issue_reference.png)
### Closing Jira Issues
Jira issues can be closed directly from GitLab by using trigger words, eg. `Resolves PROJECT-1`, `Closes PROJECT-1` or `Fixes PROJECT-1`, in commits and merge requests.
When a commit which contains the trigger word in the commit message is pushed, GitLab will add a comment in the mentioned Jira issue.
For example, for project named PROJECT in Jira, we implemented a new feature and created a merge request in GitLab.
This feature was requested in Jira issue PROJECT-7. Merge request in GitLab contains the improvement and in merge request description we say that this merge request `Closes PROJECT-7` issue.
Once this merge request is merged, Jira issue will be automatically closed with a link to the commit that resolved the issue.
![A Git commit that causes the Jira issue to be closed](merge_request_close_jira.png)
![The GitLab integration user leaves a comment on Jira](jira_service_close_issue.png)
## Configuration
### Configuring JIRA
We need to create a user in JIRA which will have access to all projects that need to integrate with GitLab. We need to create a user in JIRA which will have access to all projects that need to integrate with GitLab.
Login to your JIRA instance as admin and under Administration go to User Management and create a new user. Login to your JIRA instance as admin and under Administration go to User Management and create a new user.
...@@ -10,7 +58,7 @@ As an example, we'll create a user named `gitlab` and add it to `jira-developers ...@@ -10,7 +58,7 @@ As an example, we'll create a user named `gitlab` and add it to `jira-developers
**It is important that the user `gitlab` has write-access to projects in JIRA** **It is important that the user `gitlab` has write-access to projects in JIRA**
## Configuring GitLab ### Configuring GitLab
### GitLab 7.8 EE and up with JIRA v6.x ### GitLab 7.8 EE and up with JIRA v6.x
...@@ -27,19 +75,15 @@ Fill in the required details on the page: ...@@ -27,19 +75,15 @@ Fill in the required details on the page:
* `username` The username of the user created in [configuring JIRA step](#configuring-jira). * `username` The username of the user created in [configuring JIRA step](#configuring-jira).
* `password` The password of the user created in [configuring JIRA step](#configuring-jira). * `password` The password of the user created in [configuring JIRA step](#configuring-jira).
* `api version` The version of the JIRA API. By default, version `2` is used. * `api version` The version of the JIRA API. By default, version `2` is used.
* `Jira issue transition` This is the id of a transition that moves issues to a closed state. You can find this number under [JIRA workflow administration](jira_workflow_screenshot.png). By default, this id is `2`. (In the example image, this is `2` as well) * `Jira issue transition` This is the id of a transition that moves issues to a closed state. You can find this number under [JIRA workflow administration, see screenshot](jira_workflow_screenshot.png). By default, this id is `2`. (In the example image, this is `2` as well)
After saving the configuration, your GitLab project will be able to interact with the linked JIRA project. After saving the configuration, your GitLab project will be able to interact with the linked JIRA project.
This will allow users to mention JIRA issues in comments in merge requests and comments on commits by mentioning the issue as such:
`PROJECT-5`.
You can close JIRA issues by writing `Resolves PROJECT-5` or `Closes PROJECT-5` in commits and merge requests. After pushing the commit or merging the merge request, the referenced JIRA issue will be automatically closed.
![example of mentioning or closing the JIRA issue](jira_issue.png) ### GitLab 6.x-7.7 with JIRA v6.x
**Note: GitLab 7.8 and up contain various integration improvements. We strongly recommend upgrading.**
### GitLab 6.x-7.7 with JIRA v6.x
In `gitlab.yml` enable [JIRA issue tracker section by uncommenting the lines](https://gitlab.com/subscribers/gitlab-ee/blob/6-8-stable-ee/config/gitlab.yml.example#L111-115). In `gitlab.yml` enable [JIRA issue tracker section by uncommenting the lines](https://gitlab.com/subscribers/gitlab-ee/blob/6-8-stable-ee/config/gitlab.yml.example#L111-115).
This will make sure that all issues within GitLab are pointing to the JIRA issue tracker. This will make sure that all issues within GitLab are pointing to the JIRA issue tracker.
...@@ -64,12 +108,5 @@ Next, go to the services page and find JIRA. ...@@ -64,12 +108,5 @@ Next, go to the services page and find JIRA.
1. Optional: supply the JIRA issue transition ID (issue transition to closed). This is dependant on JIRA settings, default is 2 1. Optional: supply the JIRA issue transition ID (issue transition to closed). This is dependant on JIRA settings, default is 2
1. Save 1. Save
Now we should be able to interact with JIRA issues, for example we can close a JIRA issue by commiting to our GitLab repository and referencing the JIRA issue( in the format of JIRAPROJECT-123). Now we should be able to interact with JIRA issues.
For example, for project named NEW we commit with a commit message `Add new file fixes NEW-1`:
![A Git commit that causes the JIRA issue to be closed](jira_service_commit.png)
That will close an issue NEW-1 in JIRA and add a comment with a link to the commit that closed the issue:
![The GitLab integration user leaves a comment on JIRA](jira_service_close_issue.png)
...@@ -292,7 +292,7 @@ describe GitPushService do ...@@ -292,7 +292,7 @@ describe GitPushService do
service.execute(project, user, @oldrev, @newrev, @ref) service.execute(project, user, @oldrev, @newrev, @ref)
WebMock.should have_requested(:post, api_mention_url).with( WebMock.should have_requested(:post, api_mention_url).with(
body: /mentioned JIRA-1 in/ body: /mentioned this issue in/
).once ).once
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment