rally_api查询基于迭代获取缺陷

时间:2014-03-05 07:42:20

标签: ruby-on-rails ruby json ruby-on-rails-3 rally

我在Ruby中使用rally_api gem。任何人都可以建议我如何编写在特定迭代下获得所有缺陷的查询吗?

require 'rally_api'
headers = RallyAPI::CustomHttpHeader.new()
headers.version = "1.0"

config = {:base_url => "https://rally1.rallydev.com/slm"}
config[:username]   = "mvcmxb"
config[:password]   = "kjkjk"
config[:workspace]  = "Persons"
config[:project]    = "Business he does"
config[:headers]    = headers 

@rally = RallyAPI::RallyRestJson.new(config)

test_query = RallyAPI::RallyQuery.new()
test_query.type = "defect"
test_query.fetch = true

results = @rally.find(test_query)   

1 个答案:

答案 0 :(得分:1)

以下是通过迭代查询缺陷并更新其描述的代码示例。您可以按迭代名称查询:

query.query_string = "(Iteration.Name = \"i10\")"

或迭代参考:

query.query_string="(Iteration = /iteration/13589769934)"

名称不是唯一的,但查询也受项目约束:

rally = RallyAPI::RallyRestJson.new(config)
query = RallyAPI::RallyQuery.new()
query.type = :defect  
query.fetch = "Name,FormattedID,Iteration,Description"
query.project = {"_ref" => "https://rally1.rallydev.com/slm/webservice/v2.0/project/12352608219.js" } 
query.project_scope_up = false
query.project_scope_down = false
query.order = "Name Asc"
#query.query_string = "(Iteration.Name = \"i10\")"
query.query_string="(Iteration = /iteration/13589769934)"

results = rally.find(query)

results.each do |d|
    puts "FormattedID: #{d["FormattedID"]}, Iteration: #{d["Iteration"]["Name"]}"
    d.read
    fieldUpdates = { "Description" => "bad defect"}
    d.update(fieldUpdates)
end