Skip to content

akraxx/gitlab-jira-integration

Repository files navigation

gitlab-jira-integration

Build Status Coverage Status License Maven Central Issue Stats

If you are using GitLab Community Edition and you want to fully integrate gitlab with JIRA (ie. comment issues), you can use this project. It's a standalone java service which provides endpoints to intercepts hook events from gitlab and use JIRA REST api to interacts with issues.

Requirements

  • A JVM (jdk 8)
  • An account on JIRA which can comment issues on projects
  • An account on gitlab to have a private_token (admin rights are not required)

How to use

  • Download the fatjar gitlab-jira-integration-application from maven central
  • Create a yaml file as follow and configure it
server:
  applicationConnectors:
    - type: http
      port: 9090

  adminConnectors:
    - type: http
      port: 9091

logging:
  appenders:
    - type: console
      logFormat: "%-5p [%d{ISO8601,UTC}] [%thread] [%c{5}] %m%n%rEx"
      
password: test-password

jira:
  username: gitlab
  password: gitlab
  url: http://localhost:8090

gitlab:
  private_token: N1bJ4n8-rbFAEf8Syrh2
  url: http://192.168.59.104:8080
  
  • Launch your JAR like this : java -jar gitlab-jira-integration-application.jar server properties.yml

If everything is ok you should have something like this in your console :

INFO  [2015-10-10 17:48:43,361] [main] [i.d.j.DropwizardResourceConfig] [hookId:-] : The following paths were found for the configured resources:

    POST    /hook (fr.mmarie.resources.HookResource)

INFO  [2015-10-10 17:48:43,365] [main] [o.e.j.s.h.ContextHandler] [hookId:-] : Started i.d.j.MutableServletContextHandler@43a0a32d{/,null,AVAILABLE}
INFO  [2015-10-10 17:48:43,371] [main] [i.d.s.AdminEnvironment] [hookId:-] : tasks = 

    POST    /tasks/log-level (io.dropwizard.servlets.tasks.LogConfigurationTask)
    POST    /tasks/gc (io.dropwizard.servlets.tasks.GarbageCollectionTask)

INFO  [2015-10-10 17:48:43,376] [main] [o.e.j.s.h.ContextHandler] [hookId:-] : Started i.d.j.MutableServletContextHandler@5aaaa446{/,null,AVAILABLE}
INFO  [2015-10-10 17:48:43,394] [main] [o.e.j.s.ServerConnector] [hookId:-] : Started application@794b435f{HTTP/1.1}{0.0.0.0:9090}
INFO  [2015-10-10 17:48:43,398] [main] [o.e.j.s.ServerConnector] [hookId:-] : Started admin@38f2e97e{HTTP/1.1}{0.0.0.0:9091}
INFO  [2015-10-10 17:48:43,399] [main] [o.e.j.s.Server] [hookId:-] : Started @3812ms

You need to generate a token to authenticate your hook, format of the token is : [service:pwd] encoded in Base64, where service is any value you want to identify your gitlab hook, and password is the one defined in the YAML configuration file.

  • Add a new WebHook service in gitlab settings to : http://[IP/HOSTNAME]:9090/hook?token=[see above]

  • Commit messages with a JIRA issue prefixed by # will be mentionnd in issue comments. (For example : #TESTGIT-1)

Transitions

Since version 0.5.0 it's possible to perfom transition on JIRA issues (ie Close, Fix...) :

To do that, you need to add this part to your configuration :

jira:
  # Username, pwd...
  transitions:
    - name: Closed
      # Case insensitive
      keywords:
        - closed
        - closes
        - close
        - fixed
        - fixes
        - fix

Example of commit messages working with previous configuration :

Test Closes #TESGITLAB-3

Hello World FIX #TESGITLAB-15

This message will close both issues :

Hello World FIX #TESGITLAB-25 and Close #TESGITLAB-47

To edit your transitions in JIRA, take a look at the jira documentation

The change will be also commented in the jira issue activity to notify in which commit the issue has been closed (or any other transition)

Note : The default resolution will be taken, it only manage transition

Dependencies

About

WebService which intercept hook events from gitlab and use JIRA REST api to interact with issues.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages