At my company, we recently started using Rally for our project management tool. Initially, someone external to our team invested a lot of time manually creating iterations using a naming convention that is just not going to jive with our team's existing scheme. Instead of asking this poor soul to delete these empty iterations by hand, one by one, I would like to automate this process using Rally's REST API. In short, we need to delete these 100+ empty iterations which span across 3 different projects (which all sharing a common parent).
在我的公司,我们最近开始使用Rally作为我们的项目管理工具。最初,我们团队外部的人投入了大量时间,使用命名约定手动创建迭代,这种约定与我们团队现有的方案无关。我不想让这个可怜的灵魂一个接一个地手动删除这些空迭代,而是希望使用Rally的REST API自动化这个过程。简而言之,我们需要删除这些100多个空迭代,这些迭代跨越3个不同的项目(它们共享一个共同的父项)。
I have spent some time looking at the rally-rest-api ruby gem, and although I have some limited Ruby experience, the Query interface of the API remains confusing to me, and I am having some trouble wrapping my head around it. I know what my regex would like, but I just don't know how to supply that to the query.
我花了一些时间来看看rally-rest-api ruby gem,虽然我有一些有限的Ruby经验,但是API的查询界面仍然让我感到困惑,而我在绕过它时遇到了一些麻烦。我知道我的正则表达式会是什么,但我只是不知道如何将其提供给查询。
Here is what I have so far:
这是我到目前为止:
require 'rubygems'
require 'rally_rest_api'
rally = RallyRestAPI.new(:username => "myuser",
:password => "mypass")
regex = /ET-VT-100/
# get all names that match criteria
iterations = rally.find(:iteration) { "query using above regex?" }
# delete all the matching iterations
iterations.each do |iteration|
iteration.delete
end
Any pointers in the right direction would be much appreciated. I feel like I'm almost there.
任何指向正确方向的人都会非常感激。我觉得我差不多了。
2 个解决方案
#1
8
I had to do something similar to this a few months back when I wanted to rename a large group of iterations.
几个月前,当我想重命名一大堆迭代时,我不得不做类似的事情。
First, make sure that the user you are authenticating with has at least "Editor" role assigned in all projects from which you want to delete iterations. Also, if you have any projects in your workspace which you do not have read permissions, you will have to first supply a project(s) element for the query to start from. (You might not even know about them, someone else in your organization could have created them).
首先,确保您要进行身份验证的用户至少在要删除迭代的所有项目中分配了“编辑器”角色。此外,如果您的工作区中有任何项目没有读取权限,则必须首先提供项目元素以供查询开始。 (您可能甚至不知道它们,组织中的其他人可能已经创建了它们)。
The following gets a reference to the projects and then loops through the iterations with the specified regex:
以下内容获取对项目的引用,然后使用指定的正则表达式遍历迭代:
require 'rubygems'
require 'rally_rest_api'
rally = RallyRestAPI.new(:username => "myuser",
:password => "mypass")
# Assumes all projects contain "FooBar" in name
projects = rally.find(:project) { contains :name, "FooBar"}
projects.each do |project|
project.iterations.each do |iteration|
if iteration.name =~ /ET-VT-100/
iteration.delete
end
end
end
#2
4
Try:
iterations = rally.find(:iteration) { contains :name, "ET-VT-100" }
This assumes that the iteration has ET-VT-100 in the name, you may need to query against some other field. Regexes are not supported by the REST api, afaict.
这假设迭代在名称中有ET-VT-100,您可能需要查询其他字段。 REST api不支持正则表达式。
#1
8
I had to do something similar to this a few months back when I wanted to rename a large group of iterations.
几个月前,当我想重命名一大堆迭代时,我不得不做类似的事情。
First, make sure that the user you are authenticating with has at least "Editor" role assigned in all projects from which you want to delete iterations. Also, if you have any projects in your workspace which you do not have read permissions, you will have to first supply a project(s) element for the query to start from. (You might not even know about them, someone else in your organization could have created them).
首先,确保您要进行身份验证的用户至少在要删除迭代的所有项目中分配了“编辑器”角色。此外,如果您的工作区中有任何项目没有读取权限,则必须首先提供项目元素以供查询开始。 (您可能甚至不知道它们,组织中的其他人可能已经创建了它们)。
The following gets a reference to the projects and then loops through the iterations with the specified regex:
以下内容获取对项目的引用,然后使用指定的正则表达式遍历迭代:
require 'rubygems'
require 'rally_rest_api'
rally = RallyRestAPI.new(:username => "myuser",
:password => "mypass")
# Assumes all projects contain "FooBar" in name
projects = rally.find(:project) { contains :name, "FooBar"}
projects.each do |project|
project.iterations.each do |iteration|
if iteration.name =~ /ET-VT-100/
iteration.delete
end
end
end
#2
4
Try:
iterations = rally.find(:iteration) { contains :name, "ET-VT-100" }
This assumes that the iteration has ET-VT-100 in the name, you may need to query against some other field. Regexes are not supported by the REST api, afaict.
这假设迭代在名称中有ET-VT-100,您可能需要查询其他字段。 REST api不支持正则表达式。