How to install and configure the Jira Git plugin with Gitlab

2 minute read

Introduction

Before I continue let me tell you that the Jira Git Plugin that I will talk about is not supported by Atlassian but Marcello Teodori added support for version 5 of Jira.  If you want a supported plugin you can see the Git Version Control Viewer supported by BigBrassBand, I will not talk about it because I didn't try it.

Requirements

Let's start

First of all, you should know that it can be done with two different environments:

  1. Having Jira in one server and Gitlab with git in other server
  2. Have both in the same server

Step 1 - Install the Jira Git Plugin

  1. Open Jira
  2. Go to: Administration > Plugins > Manage Plugins
  3. Click on "Upload Plugin"
  4. Add the url for the plugin: https://github.com/downloads/mteodori/jira-git-plugin/jira-git-plugin-0.6.1-SNAPSHOT.jar
  5. Click on upload

By now you should have Jira Git Plugin installed.

Step 2 - Configure the Git repositories

For every single repository you will need to clone it and add the configuration for it inside Jira. Since you can have two different environments let's do it for both.

1. Jira and Gitlab on the same server

  1. git clone (with or without --bare) the source tree that you need (run as the same user that Jira runs as). Ex.: git clone --bare git@localhost:test /home/jira/repositories/test
  2. Go to: Open Jira > Administration section > Plugins > Git Repositories > click on Add
  3. Display Name: Your repository name. Ex.: Test
  4. Repository root: Directory where you cloned your repository. Ex.: /home/jira/repositories/test
  5. Repository Origin: The url you used to clone the repository. Ex.: git@localhost:teste.git
  6. Web Linking: For the current version of Jira Git Plugin does not exist the default Gitlab formats but you can add them manually:
    1. View format: http://<gitlab server>/<repository>/master/tree
    2. Changeset format: http://<gitlab server>/<repository>/commits/${rev}
    3. File added, modified and deleted are the same formar: http://<gitlab server>/<repository>/commits/${rev}#${path}

2. Jira and Gitlab on different servers

You have two choices here:

  1. Add the private ssh key of gitlab user to the user that Jira runs
  2. Create a new user on Gitlab for Jira and generate the ssh key for that user on the Jira server.
First one:
  1. Copy the ssh key of the gitlab user (on the Gitlab server) to the user that Jira runs as (on Jira server)
  2. Now you can follow the Jira and Gitlab on the same server steps

Second one:

  1. Generate the ssh key for the user that Jira runs as (on Jira server)
  2. Create the Jira user inside Gitlab
  3. Add the public ssh key for the user that you create on step 1
  4. Add the user to the repositories you want (at least with the reporter role)
  5. Now you can follow the Jira and Gitlab on the same server steps

edited:  added the Jira version supported by this plugin

Leave a Comment