开发者

Using the Rally Rest API for CRUD operations

开发者 https://www.devze.com 2023-02-09 07:30 出处:网络
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 th

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).

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.

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 rig开发者_如何学运维ht direction would be much appreciated. I feel like I'm almost there.


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消