【问题标题】:What is the easiest way to extract sprint start and end dates from the JIRA db?从 JIRA db 中提取 sprint 开始和结束日期的最简单方法是什么?
【发布时间】:2011-12-14 07:02:22
【问题描述】:

我正在尝试从 Jira 数据库中提取我的 sprint 的开始和结束日期。这似乎是一项简单的任务,但实际上(至少据我所知)并非如此。

在试图弄清楚这一点时,我找到了一种解决方案,但在我看来,它是如此繁琐和困难,以至于我认为这是唯一的方法。

这是我发现的:

Sprint 不是原生 Jira 表达式,Greenhopper 插件使用 projectversion 表来表示 sprint。

projectversion 表包含有关 sprint 的一些信息,例如名称、所属项目以及发布日期。发布日期可以认为是 sprint 的结束日期,但缺少开始日期。

如果您背靠背冲刺,也许冲刺的开始日期可以设置为前一个冲刺的发布日期加上一天?但这确实不是一个好的解决方案。

所以我搜索了 Jira 数据模型,我发现对 sprint 开始日期的最佳且唯一的参考是在属性结构中。

您可以定义属性并为其分配值。在这个结构的主表 propertyentry 表中,我发现了这样的条目:

ID     ENTITY_NAME     ENTITY_ID     PROPERTY_KEY                          propertytype    
-----  --------------  ------------  ------------------------------------  ------------
 10288  GreenHopper     10010         CONFIGURATION                         6               
 10304  GreenHopper     10012         CONFIGURATION                         6               
 10312  GreenHopper     10013         CONFIGURATION                         6               
 10449  GreenHopper     10014         CONFIGURATION                         6   

所以 GreenHopper 添加了一个属性,其键设置为 CONFIGURATION。 etity_id 字段引用 project.id 并且配置属性是项目配置。 property_type 设置为 6,它告诉我们在 propertytext 表中查找值。

propertytext 表中存储的值显示为 XML 字符串,其中包含有关项目的不同信息,其中条目如下:

<entry>
  <string>BURNDOWN_START_DATE_10074</string>
  <long>1316988000000</long>
</entry> 

就是这样。我找到的最好的 sprint 开始日期。隐藏在属性表中的 xml 字符串中。

我的问题是:这真的是找到我的 sprint 开始日期的唯一方法吗?

【问题讨论】:

  • 为什么一定要直接使用数据库?有一些选项可以显示您的 sprint 视图(在 JIRA 版本中)......如果您需要数据,我会首先尝试使用 JIRA 的 API 来获取信息。
  • 我使用数据库来提取我无法通过 Jira Web 应用程序获取的工作日志信息。就像每个团队成员每天记录的小时数报告一样。我将研究 Jira API,看看它提供了什么。

标签: mysql sql database jira jira-agile


【解决方案1】:

似乎无法通过 Jira SOAP/REST API 获取 sprint 的结束和开始日期。

您可以使用以下方法提取 sprint 的开始和结束日期: com.pyxis.greenhopper.jira.configurations.ProjectConfiguration#getVersionStartDate com.pyxis.greenhopper.jira.configurations.ProjectConfiguration#getVersionEndDate

要使用这个类,你可以编写一个 Jira 插件 - Developing with the Atlassian Plugin SDK

另一种选择是编写 GreenHopper 模块 - GreenHopper Developer Documentation

【讨论】:

  • 如何获得版本对象引用?
  • 实际上,您可以使用 JIRA Agile REST API 获取 sprint 的开始和结束日期:/rest/greenhopper/1.0/rapid/charts/sprintreport.json?rapidViewId=652&sprintId=577 和查看 sprint 元素。它还附带 sprint 中已完成的问题
【解决方案2】:

如果可以避免的话,我不建议直接访问 JIRA 数据库。未记录的 JIRA Agile REST API,例如 rest/greenhopper/1.0/rapid/charts/sprintreport.json?rapidViewId=652&sprintId=577 其中 rapidViewId 是板 id, 为您提供 Sprint 信息。这个和其他 REST 资源可以在 jira-python 库中看到,http://jira-python.readthedocs.org/en/latest/

【讨论】:

  • 日期格式为:startDate: 07/Nov/13 3:40 PM endDate: 31/Dec/13 3:40 PM
【解决方案3】:

在 Agile jira 中查找 sprint 开始日期和结束日期的最简单方法是点击 jiraschema.AO_60DB71_SPRINT 表。这会将start_dateend_date 存储为大整数。由于某些原因,Jira 将这些日期格式存储为 int 数据类型。要将 int 转换为 date 数据类型,这里是 MS Sql 中的查询。如果需要,您可以轻松地将其更改为其他数据库。

###This query pulls start_date, end_date, completed_date of all non active sprints in MS SQL.###

select ID, Name SprintName
,START_DATE / 60 / 60 / 24 / 1000  + CAST('12/31/1969' as datetime)+1 StartDate
,END_DATE / 60 / 60 / 24 / 1000  + CAST('12/31/1969' as datetime)+1 EndDate
,COMPLETE_DATE / 60 / 60 / 24 / 1000  + CAST('12/31/1969' as datetime)+1 CompletedDate
FROM
 AO_60DB71_SPRINT as sprint
where COMPLETE_DATE is not null

【讨论】:

  • 你能解释一下为什么每个末尾都有一个+1,是为了允许一个特定的时区吗?此外,这始终显示为四舍五入。
【解决方案4】:

SELECT * FROM a0_60db71_sprint

这是一个 MySQL 问题,而不是 java

连接到您的 JIRA MySQL 数据库并查找与 *_sprint 匹配的表

上表的字段为:

  • Closed (boolean)
  • ID (key)
  • Start_Date (timestamp)
  • End_Date (timestamp)
  • Complete_Date (timestamp)

【讨论】:

  • 您假设 MySQL 是正在使用的数据库并且违反了 Active Objects 抽象。
【解决方案5】:

我最近接到了一项任务,即获取特定项目的冲刺列表以及日期。首先,我需要从 Project 表中找到项目 ID,并从表 customfield/customfieldvalue 中找到字段 Sprint 的 customfield ID。

这是结果

select 
    p.pname as "Project Name",
    s.NAME as "Sprint Name", 
    from_unixtime(s.START_DATE / 1000) as "Start Date", 
    from_unixtime(s.END_DATE / 1000) as "End Date",
    from_unixtime(s.COMPLETE_DATE / 1000 ) as "Complete Date"
from
    customfieldvalue as c, 
    jiraissue as i, 
    project as p, 
    AO_60DB71_SPRINT as s
where 
    p.id = <project ID> and p.id = i.project and
    c.issue = i.id and c.customfield = <customfield ID> and
    c.stringvalue = s.id
group by s.name 
;

我们的mysql服务器在不同的时区,所以我不得不修改输出时间。

...
    from_unixtime(s.START_DATE / 1000) - interval 1 hour as "Start Date", 
...

也许它会帮助某人

【讨论】:

    【解决方案6】:

    不确定!为什么 JIRA 不提供一个非常简单的 Rest Endpoint 来吐出所有 sprint 信息。为什么我必须处理 board/boardID 才能在该板上查找 sprint,为什么我必须遍历所有 sprint。

    我是管理员用户,但仍然会遇到一些 sprint # 给我,Sprint does not exist

    无论如何,这里有一个变通的脚本。

    #!/bin/bash
    
    JIRA_URL="http://my_jira_server:8080"
    
    users_sprint_limit_cmd_line_arg="$1"
    # First parameter passed to the script is a NUMBER (for how many sprints a user wants to iterate over.
    ## I know!! it's a work-around for dealing with "Sprint does not exist" and
    ## becasue there's no shitty direct JIRA Rest API that exist, to query JIRA server, to spit all SPRINTS with info (start/end date) in just one call.    
    
    ## You can use API token (or base64 hash). I'm just going rouge here.
    user="a_user_user_who_can_read_any_sprint_or_serviceuser_or_admin"
    pass="D00M4u!"
    
    ## Set build number variable
    b_no=${BUILD_NUMBER:="999999"}
    
    ## At the end, you'll have a Temp file will store all sprints info, Valid will contain only valid sprints.
    temp_sprint_file="/tmp/all_sprints_startdates_${b_no}_temp.txt"
    valid_sprint_file="/tmp/all_sprints_startdates_${b_no}.txt"
    
    
    ## Clean files
    rm ${temp_sprint_file} ${valid_sprint_file} || true;
    
    ## Sprint counter
    sprint_no=1
    
    result="ToBeSet"
    ## Iterate over all sprints and find their start/stop dates.
    ## -- This is one-odd way to find sprint's start/end dates, but it works!!
    ## -- A user can pass a larger value in while condition "-lt value" via cmd line 1st param.
    while [[ $sprint_no -lt ${users_sprint_limit_cmd_line_arg} ]];
    do
        ## assumes 'jq' is installed. --OR run: sudo yum install jq
        ## --------------------------
        result="$(curl -s -u $user:$pass -X GET -H 'Content-Type: application/json' "${JIRA_URL}/rest/agile/1.0/sprint/${sprint_no}" | \
                  jq | \
                  egrep "name|startDate|endDate" | \
                  cut -d'"' -f4 | \
                  sed "s/T[0-9][0-9]:[0-9][0-9].*$//" | \
                  tr '\012' ',' | \
                  sed "s/,$//")";
        echo "${result}" >> ${temp_sprint_file}
        ((sprint_no++));
    done
    
    ## Find valid sprints which have valid start/end dates.
    grep "[A-Za-z],[0-9].*,[0-9]" ${temp_sprint_file} > ${valid_sprint_file};
    
    echo -e "\n\n-- Sprints and Start/End Date file is available here: ${valid_sprint_file}\n\n"
    

    在这个生成的 sprint 数据文件上运行 cat 命令会给你,比如:

     1  Trumpy Trump,2019-01-09,2019-01-23
     2  Magical Modi,2019-01-18,2019-02-01
    

    您可以在上面的脚本中添加一行,通过具有标题行(即 Sprint_Name、Sprint_Start_Date、Sprint_End_Date)将其用作纯 CSV 文件,我只是没有这样做,因为我的用例只是使用此文件作为参考文件。

    关于日期的相关帖子:BASH:How to find no. of days (considering only "Network / Business Days") between two dates (i.e. exclude weekends Saturday/Sunday)

    【讨论】:

      猜你喜欢
      • 2023-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多