Integrate Redmine with GitLab

部門選用了 Redmine 當作我們的專案管理系統.想要規範 git commit 的訊息,並將這些訊息自動發佈到 GitLab 上, 來節省開發人員的時間.

測試環境

使用docker建立測試環境

先啟動Redmine在啟動Gitlab

網段配置

在docker-gitlab/docker-compose.yml中新增下面設定,為了將兩個服務在同一網段下.

services:
  web:
    image: 'gitlab/gitlab-ce:12.3.1-ce.0'
    ...
    networks:
      - default

networks:
  default:
    external:
      name: docker-redmine_default
本次測試服務IP位置
設定hosts,透過域名互通
sudo echo '172.30.0.4 gitlab.example.com' >> /etc/hosts
sudo echo '172.30.0.3 redmine.example.com' >> /etc/hosts

設定redmine

安裝plugin

希望 git push 時觸發 Redmine, 所以要加入此 plugin. git clone redmine_gitlba_hook到 plugins 的資料夾中. 再來可以在Administration » Plugins » GitLab Authentication中做設定,目前設定如下.

參數說明
All branchesv
Prune
Auto createv自動建立repo
Local repositories path/usr/src/redmine/reporedmine拉repo的位置,要注意權限,需要redmine可以寫入的權限
Git command prefix
Fetch updates from repositoryv

設定API Key

Administration » Settings » Repositories中Enable WS for repository management再Generate a key. 這裡取得了Key:rYtIYdc2zR9ZvZ8M24L8

建立專案

建立一個專案叫做DevOps

建立議題

需要先設定trackers,在建立一筆Issue,建立完成後index應該是#1.

設定專案

建立一個叫做DevOps的專案,設定專案下的integrations » redmine.

參數
ActiveV
DescriptionRedmine issue tracker
Project urlhttp://redmine.example.com/projects/devops
Issues urlhttp://redmine.example.com/issues/:id
New issue urlhttp://redmine.example.com/projects/devops/issues/new

建立一個webhook來觸發redmine_gitlba_hook,設定專案下的integrations.

URL如下:

or