4

我正在尝试从 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 开始日期的唯一方法吗?

4

6 回答 6

2

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

于 2013-12-24T16:33:56.013 回答
2

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

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

要使用此类,您可以编写一个 Jira 插件 -使用 Atlassian 插件 SDK 进行开发

另一种选择是编写 GreenHopper 模块 - GreenHopper 开发者文档

于 2011-12-15T02:42:55.750 回答
1

在 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
于 2013-12-24T07:45:03.817 回答
1

SELECT * FROM a0_60db71_sprint

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

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

上表中的字段是:

  • Closed (boolean)
  • ID (key)
  • Start_Date (timestamp)
  • End_Date (timestamp)
  • Complete_Date (timestamp).
于 2013-01-16T17:05:42.127 回答
1

我最近接到了一项任务,以获取包含特定项目日期的 sprint 列表。首先,我需要从项目表中找到项目 ID,并从表 customfield/customfieldvalue 中找到字段 Sprint 的自定义字段 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", 
...

也许它会帮助某人

于 2014-02-24T13:38:37.370 回答
0

没有把握!为什么 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:如何找到没有。两个日期之间的天数(仅考虑“网络/工作日”)(即不包括周末周六/周日)

于 2020-02-24T15:18:54.373 回答