Skip to content

a php class advanced integration GitLab CE(Community Edition) and Atlassian's JIRA.

Notifications You must be signed in to change notification settings

SuperFra/gitlab-jira-integration

 
 

Repository files navigation

GitLab JIRA Integration

What is it?

GitLab-JIRA-Integration is a small PHP standalone app executed by gitlab web hooks and interact with JIRA using JIRA-REST API. If you have questions contact to me or open an issue on GitHub.

How it works.

How it works.

Requirements

  • PHP > 5.4
  • Lumen framework > 5.0
  • php-jira-rest-client
  • Atlassian JIRA 6 or above
  • Gitlab CE 6 or above

Installation

  1. Download and Install PHP Composer.

    curl -sS https://getcomposer.org/installer | php
  2. clonning gitlab-jira-intergration project

    $ git clone https://github.com/lesstif/gitlab-jira-integration.git
  3. Run the composer install command.

    $ composer install
  4. Now you need define your a Jira and Gitlab connection info into .env configuration.

    JIRA_HOST="https://your-jira.host.com"
    JIRA_USER="jira-username"
    JIRA_PASS="jira-password"
    GITLAB_HOST="https://your-gitlab.host.com"
    GITLAB_TOKEN="gitlab-private-token-for-api"
    

Tip: In the following steps, you will generate your private token for API.

  • login gitlab and click on Profile Settings
  • Click on Account
  • Here, You can find your private token. Private Token

Next, copy config.integration.example.json to config.integration.json. sh $ cp config.integration.example.json config.integration.json

Here is the default configuration, for interact with Jira.

{
    "accept.host": [
        "localhost",
        "your-gitlab-host-here"
    ],
    "transition": {
        "message": "[~%s] Issue %s with %s",
        "keywords": [
            [
                "Resolved",
                "[resolve|fix]"
            ],
            [
                "Closed",
                "[close]"
            ]
        ]
    },
    "referencing": {
        "message": "[~%s] mentioned this issue in %s"
    }
}

transition

  • message : "[~%s] issue %s with %s" : Converted to "User Issue Resolved with Commit URL"
  • keywords: if commit message had second element(eg: resolve or fix),then issue status transition to first element.(eg : Resolved)

Usage

Run PHP standalone web server on the gitlab-jira integration server. (eg: my-host.com).

php artisan serve --host 0.0.0.0 --port 9000

Configuration

gitlab configuration

Tip: If you decide to change the hook receiving URI from the default, Open the app/Http/routes.php file in a text editor and find this line:

$app->post('gitlab/hook',[
	'as' => 'hook', 'uses' => 'GitlabController@hookHandler'
]);

change to 'gitlab/hook' to desired the URI (eg: 'gitlab/my-hook-receiver')

Referencing JIRA isssues

  • git commit with JIRA Issue Key(eg. TEST-123 or test-123)
  • Gitlab-Jira-Integrator will automatically add a comment in specific JIRA Issue.

Resolving or Closing JIRA isssues

  • git commit with JIRA Issue Key and trigger keywords(eg. 'Closed TEST-123' or 'fix test-123')
  • Gitlab-Jira-Integrator will automatically add a comment and closing(or fixing) directly in specific JIRA Issue by using trigger keywords(setting in config.integration.json) in commit message.

License

Apache V2 License

See Also

About

a php class advanced integration GitLab CE(Community Edition) and Atlassian's JIRA.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 98.6%
  • Other 1.4%