English 中文(简体)
Using the Rally Rest API for CRUD operations
原标题:

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





相关问题
Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

multiple ruby extension modules under one directory

Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script? Background: I ve a project with two extension modules, foo.so and bar.so which ...

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

热门标签