从JIRA数据库中提取sprint开始和结束日期的最简单方法是什么?

时间:2011-12-14 07:02:22

标签: mysql sql database jira jira-agile

我正在尝试从Jira数据库中提取短跑的开始和结束日期。这似乎是一项简单的任务,但它确实(至少我发现)并非如此。

在尝试解决这个问题时,我发现了一个解决方案,但在我看来这么麻烦和困难,以至于我有问题,认为这是唯一的方法。

这是我发现的:

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

projectversion表包含有关sprint的一些信息,例如名称,它属于哪个项目以及发布日期。发布日期可以被视为sprint结束日期,但缺少开始日期。

如果你背靠背冲刺,也许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字符串中。

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

6 个答案:

答案 0 :(得分:2)

似乎没有办法通过 Jira SOAP / REST API 获得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

答案 1 :(得分:2)

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

的jira-python库中看到此资源和其他REST资源

答案 2 :(得分:1)

SELECT * FROM a0_60db71_sprint

这是 MySQL 问题,而不是 java

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

匹配的表格

上表中的字段为:

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

答案 3 :(得分:1)

我最近获得了一项任务,以获取具有特定项目日期的冲刺列表。首先,我需要从项目表中找到项目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", 
...

也许它会帮助某人

答案 4 :(得分:0)

在Agile jira中查找sprint的开始日期和结束日期的最简单方法是点击jiraschema.AO_60DB71_SPRINT表。这会将start_dateend_date存储为大整数。 Jira由于某些原因将这些日期格式存储为int数据类型。要将int转换为日期数据类型,这里是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

答案 5 :(得分:0)

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

我是管理员用户,但仍然遇到一些冲刺#给了我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)

相关问题