jira和gerrit的集成和脚本

flow_tools的Python项目详细描述


一些自动化gerrit、jira等的工具。

当我的工作组将问题跟踪转移到jira时,这对项目来说是个福音。 但也带来了一些重大的发展摩擦。吉拉是 强大,但不快。完成任何事情大约需要12次点击 而且似乎每个ui交互都涉及到大量的数据库更新。

flow-tools作为两个脚本启动,以自动化常见的耗时 与吉拉的互动。其中包括两个Gerrit->;Jira 集成也一样。

用法

usage: flow-tools [-h] [-c CONFIG] [-v] <command> ...

Command line client to automate parts of our agile workflow.

positional arguments:
  <command>
    close-issues-merged
                        Walk the list of merges on master for the given user.
                        Look for tags in the commit message indicating that
                        the commit closes/resolves an issue. Then login to
                        jira and close those issues if they are not already
                        closed.
    set-issues-fixed-in-release
                        For each issue closed in a release, set the "Fixed
                        Release" field of jira
    add-mentions-to-watchers
                        Get a list of all mentioned users in the issue
                        comments and description, and add any to the watcher
                        list that are not already watchers.
    print-releases      Parse tags on the gerrit remote and print a sorted
                        list of version strings, using the pattern and sort
                        functions from the config file.
    release-notes       Show a list of commit message summaries for each
                        commit in the series between one version and another.
    issues-in-release   Show a list of issues that were closed in a release.
                        In particular, lookup all commits that went into a
                        release (since the common ancestor with the previous
                        release). For each commit, get the list of issues
                        closed or resolved through commit message meta data.
                        These are the issues considered "in" the release.
    increment-jira-from-gerrit
                        Monitor changes on gerrit for tags indicating
                        associated issues that are resolved by those changes.
                        As a change moves through the gerrit workflow, move
                        the associated issue through the jira workflow. Same
                        as update-jira-from-gerrit but in this case the start
                        of the period to search will the last successful time
                        we ran this command, and the end time will be right
                        now.
    update-jira-from-gerrit
                        Monitor changes on gerrit for tags indicating
                        associated issues that are resolved by those changes.
                        As a change moves through the gerrit workflow, move
                        the associated issue through the jira workflow.

optional arguments:
  -h, --help            show this help message and exit
  -c CONFIG, --config CONFIG
  -v, --version         show program's version number and exit

Subcommands have their own options. Use <command> -h or <command> --help to
see specific help for each subcommand.

示例

在提到时移动到观察者

查找票证评论中提到的@-proj-1234 让他们看那张票:

flow-tools add-mentions-to-watchers PROJ-1234

简单gerrit/jira集成

要利用jira/gerrit集成,请在提交消息中添加如下标记:

Closes: bug-1234, bug-1235, bug-1236
Resolves: bug-1237, bug-1238

集成脚本将读取提交消息并为这些标记解析它们。 对于提到的任何问题,该问题将在jira中移动到 “在审查中”。然后,一旦合并了更改,任何相关联的票据 在“关闭”中,将移动到“关闭”,并且“解决”中提到的任何票据 将移至“已解决”。

要扫描过去10天更新的gerrit更改,请使用:

flow-tools update-jira-from-gerrit --project my_project \
    --start-time "$(date '+%Y-%m-%d %H:%M:%S' -d '-10 days')" \
    --end-time "$(date '+%Y-%m-%d %H:%M:%S' -d '-10 days')"

以增量方式扫描gerrit更改(自上次运行 命令或1周(如果这是您第一次运行):

flow-tools increment-jira-from-gerrit --project my_project

对于gerrit/jira集成,您可以设置一个cron作业来批处理高级问题 基于他们的gerrit状态:

crontab -e

下面是一个简单的cron作业,它将在每个 小时:

PYTHONPATH=/path/to/flow-tools
# Minute   Hour   Day of Month       Month          Day of Week        Command
# (0-59)  (0-23)     (1-31)    (1-12 or Jan-Dec)  (0-6 or Sun-Sat)
12 * * * * flow-tools increment-jira-from-gerrit --project my_project >> /path/to/flow_tools.log

配置

配置由存储在以下位置的python文件管理:

~/.flowtools/config.py

下面是一个示例。

# URL for the database that sqlalchemy should use. The database is used to
# cache certain objects fetched from either the gerrit or jira REST APIs
# and to store some state for doing incremental jobs.
db_url = "sqlite:////home/user/.flowtools/db.sqlite",

# Jira rest configuration. These are passed directly as kwargs to the
# jira rest client constructor.
jira = {
  "auth" : {
    "url" : "https://company.atlassian.net",
    "username" : "user+robo",
    "password" : "abc123!@#",
  },

  # The nominal flow of a jira ticket from the perspective of gerrit/jira
  # integration. This is used to prevent any "backwards" movement of a
  # ticket in the event that a human being changes the status of a ticket
  # before the integration script does.
  "nominal-flow" : {
    "PROJA": {
      "New": [
        "Open",
        "In Progress",
        "In Review",
        "Verify (QA)",
        "Closed"
      ],
      "Open": [
        "In Progress",
        "In Review",
        "Verify (QA)",
        "Closed"
      ],
      "In Progress": [
        "In Review",
        "Verify (QA)",
        "Closed"
      ],
      "In Review": [
        "Verify (QA)",
        "Closed"
      ],
      "Verify (QA)": [
        "Closed"
      ]
  }


},

gerrit = {
  # Gerrit rest configuration. The password is the http password added to
  # gerrit for the account. You can add an http password to an account
  # through either the web UI or command line tools.
  "rest" : {
    "url" : "https://gerrit.company.com",
    "username" : "user+robo",
    "password" : "ABDCEFGHIJKLMNOPQRSTUVWXYZXabcdefghjijklmnopqurst"
  },

  # Gerrit ssh connection information.
  "ssh" : {
    "host" : "gerrit.company.com",
    "port" : 29418
  }
},

gerrit_jira = {
  # Maps commit change message tags to jira ticket status that a ticket
  # should be transitioned to in the event that a gerrit change is
  # merged.
  "tag-map": {
    "Closes": "Closed",
    "Resolves": "QA (Resolved)"
  }
}

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Netbeans hibernate pdf报告   java如何将通用JAXBElement作为输入   java如何在Spring中注入自定义ObjectFactory   使用webview下载java 安卓 instagram视频   是否可能使用Java在OpenCL上运行C应用程序?   java AbstractTableModel使用TreeMap<Integer,Vector<Object>作为实现insertRow()的基础   java使用@Transaction和spring boot 2.1回滚每个异常   java Hibernate批处理操作性能   swing从Java对象的ArrayList创建JTable   代码可读性为什么java没有相同的功能/替代方案   java Spring创建名为“org”的bean时出错。springframework。aop。配置。内部自动加速器   java如何在JTable中维护用户指定的列宽?   java FCM通知图标未更改   kryo如何在java之外向kryonet发送数据   java当记录计数很高且某些列被索引时,如何优化Oracle DB中的插入率?   ffmpeg如何使用java程序执行cmd命令