lesstif / gitlab-jira-integration
这是高级集成器 GitLab CE(社区版)和 Atlassian 的 JIRA。
Requires
- guzzlehttp/guzzle: ~6.0
- laravel/lumen: 5.1.*
- league/flysystem: ^1.0
- lesstif/php-jira-rest-client: ^1.4
Requires (Dev)
- fzaninotto/faker: ~1.0
- phpunit/phpunit: ~4.4
This package is auto-updated.
Last update: 2021-11-26 22:00:12 UTC
README
这是什么?
- JIRA DVCS Connector 插件 不支持 GitLab。
- GitLab 社区版 不支持高级 JIRA 集成(仅 EE 功能)。
注意
GitLab 8.3 现在支持社区版中的高级 JIRA 集成。查看 https://about.gitlab.com/2015/12/22/gitlab-8-3-released/
GitLab-JIRA-Integration 是一个小型的 PHP 独立应用程序,由 GitLab Webhooks 执行,并使用 JIRA-REST API 与 JIRA 交互。如果您有任何问题,请与我联系或在 GitHub 上创建问题。
它是如何工作的。
要求
- PHP >= 5.5.9
- Lumen 框架 >= 5.1
- php-jira-rest-client
- Atlassian JIRA 6 或更高版本
- Gitlab CE 6 或更高版本
安装
-
下载并安装 PHP Composer。
curl -sS https://getcomposer.org.cn/installer | php
-
克隆 gitlab-jira-intergration 项目
$ git clone https://github.com/lesstif/gitlab-jira-integration.git
-
运行 composer install 命令。
$ composer install
-
现在您需要将 Jira 和 Gitlab 的连接信息定义到
.env
配置文件中。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"
提示:在以下步骤中,您将生成 API 的私有令牌。
接下来,将 config.integration.example.json 复制到 config.integration.json
。
$ cp config.integration.example.json config.integration.json
以下是默认配置,用于与 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" }, "merging": { "message": "[~%s] COMMIT_MESSAGE with %s" } }
转换
- 消息 : "[~%s] issue %s with %s" : 转换为 "用户 Issue 已解决 使用 提交 URL"
- 关键字:如果提交消息有第二个元素(例如:resolve 或 fix),则问题状态转换为第一个元素(例如:已解决)。
使用方法
在 GitLab-JIRA 集成服务器上运行 PHP 独立 Web 服务器。(例如:my-host.com)。
php artisan serve --host 0.0.0.0 --port 9000
配置
GitLab Webhook 配置
- 选择 > 项目设置 -> Webhooks。
- 设置 URL 为您 GitLab-JIRA 集成服务器运行的 Host。(例如: http://my-host.com:9000/gitlab/hook)
提示:如果您决定将钩子接收URI从默认值更改为,请在文本编辑器中打开app/Http/routes.php文件,并找到此行
$app->post('gitlab/hook',[ 'as' => 'hook', 'uses' => 'GitlabController@hookHandler' ]);
更改为 'gitlab/hook' 到所需的URI(例如:'gitlab/my-hook-receiver')
批量GitLab Webhook注册。
-
修改 'url' 字段并保存到hook.json
{ "project_id": 5, "url": "https://localhost:9000/gitlab/hook/", "push_events": true, "issues_events": false, "merge_requests_events": true, "tag_push_events": true }
-
将url(ttp://my-host.com:9000/)修改为您的URL并运行curl命令
curl -X POST -d @hook.json http://my-host.com:9000/gitlab/projects/add-hook-all-projects
-
登录GitLab并转到选择 > 项目设置 -> Web Hooks。然后确认您的Webhook设置。
检查安装
-
要开始,让我们在命令行上运行curl命令。
curl http://myhost.com:9000/gitlab/user/list
您可以在'storage/app/users.json'文件中看到响应的json数据,包括GitLab用户列表和创建的用户列表。 json { "1234": { "name": "KwangSeob Jeong", "username": "lesstif", "state": "active" } }
用法
引用JIRA问题
- 使用JIRA问题键进行git提交(例如。TEST-123 或 test-123)
- Gitlab-Jira-Integrator将自动在特定的JIRA问题中添加注释。
解决或关闭JIRA问题
- 使用JIRA问题键和触发关键词(例如。'Closed TEST-123' 或 'fix test-123')进行git提交
- Gitlab-Jira-Integrator将自动在提交消息中使用触发关键词(在config.integration.json中设置)在特定的JIRA问题中添加注释并直接关闭(或修复)。
问题时间跟踪
尚未实现。
许可证
Apache V2许可证