Gerrit 提交关联jira

一、背景
gerrit提交的commit message 中的jira id 能自动关联到JIRA ,同gitlab与jira的集成
二、操作步骤
2.1 下载jar包,安装插件
下载链接:https://archive-ci.gerritforge.com/job/plugin-its-jira-bazel-master-stable-3.6/
安装命令

cp its-jira.jar /data/gerrit/gerrit_application/plugins

2.2 配置项目
该插件允许将 Jira 问题与 Git 提交关联起来。
可以针对每个项目配置是否启用 Jira 集成。要为项目启用 Jira 集成,项目必须在其project.config分支文件中包含以下条目refs/meta/config:

[plugin "its-jira"]
     enabled = true

也可以在web页面上配置
2.3 添加gerrit.config配置

[its-jira]
    url=https://jira.hobot.cc:8443
    username=xxxxxx
    password=xxxxxx

[commentlink "its-jira"]
    match = ([A-Z]+-[0-9]+)
    html = "<a href=\"https://jira.hobot.cc:8443/browse/$1\">$1</a>"
    association = SUGGESTED

其他的不需要修改
MANDATORY : One or more issue-ids are required in the git commit message, otherwise the git push will be rejected.
SUGGESTED : Whenever a git commit message does not contain any issue-id, a warning message is displayed as a suggestion on the client.
OPTIONAL : Issue-ids are linked when found in a git commit message. No warning is displayed otherwise.
association三个参数根据需要调整

2.4 添加插件配置
配置文件:/data/gerrit/gerrit_application/etc/its/actions.config

[rule "open"]
    event-type = patchset-created
    action = add-standard-comment
    action = invoke-issue-restapi POST /remotelink 200,201 link
#[rule "resolve"]
#    event-type = comment-added
 #   approvalCodeReview = 2
 #   action = add-standard-comment
#[rule "merged"]
 #   event-type = change-merged
 #   action = add-standard-comment
#[rule "abandoned"]
  #  event-type = change-abandoned
  #  action = add-standard-comment
根据自身需要判断是否保留action = add-standard-comment

2.5 添加插件模板
模板文件:/data/gerrit/gerrit_application/etc/its/templates/link.soy

{namespace etc.its.templates}
{template .link}
  {@param changeUrl: string}
  {@param subject: string}
  {@param status: string}
{lb}
  "globalId": "{$changeUrl}",
  "application": {lb}
    "type": "com.googlesource.gerrit",
    "name": "Gerrit"
  {rb},
  "object": {lb}
    "url": "{$changeUrl}",
    "title": "{$subject}",
    "icon": {lb}
      "url16x16": "https://gerrit.hobot.cc:8443/favicon.ico",
      "title": "Review"
    {rb},
    "status": {lb}
      {switch $status}
        {case null}
          "resolved": false
        {case 'NEW'}
          "resolved": false
        {case 'SUBMITTED'}
          "resolved": false
        {case 'MERGED'}
          "resolved": true
        {case 'ABANDONED'}
          "resolved": true
      {/switch}
    {rb}
  {rb}
{rb}
{/template}

2.6 重启服务

/data/gerrit/gerrit_application/bin/gerrit.sh restart

2.7 参考文档
https://gerrit.googlesource.com/plugins/its-jira/+doc/master/src/main/resources/Documentation/config.md

  • 10
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值