Rally Ruby toolkit: how to get URL of Portfolio Item's state?

别说谁变了你拦得住时间么 提交于 2019-12-02 16:24:35

问题


Is there an example in Ruby using rally_api how to set State of a feature as mentioned here?

Specifically, is there a way to query the ObjectID or the fully qualified path of state to use

"State" => "Developing"

instead of

"State" => "/state/<ObjectID>"

回答1:


It is possible to query State, create a hash, and populate the hash with the query results, where State Name is the key and State _ref is the value:

state_results.each do |s|
    s.read
    state_hash[s["Name"]] = s["_ref"]
end

Then we can update a State:

features.each do |f|
    field_updates={"State" => state_hash["Developing"]}
    f.update(field_updates)
end

Here is a code example:

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

queryState = RallyAPI::RallyQuery.new()
queryState.type = :state
queryState.fetch = "true"
queryState.workspace = {"_ref" => "https://rally1.rallydev.com/slm/webservice/v2.0/workspace/11111" } 
queryState.project = {"_ref" => "https://rally1.rallydev.com/slm/webservice/v2.0/project/22222" } #use valid OIDs
queryState.query_string = "(TypeDef.Name = \"Feature\")"

state_hash = Hash.new

state_results = @rally.find(queryState)

state_results.each do |s|
    s.read
    #puts "Ref: #{s["_ref"]}, Name: #{s["Name"] }, TypeDef: #{s["TypeDef"]}" 
    state_hash[s["Name"]] = s["_ref"]
end 

query = RallyAPI::RallyQuery.new()
query.type = "portfolioitem/feature"
query.fetch = "Name,FormattedID"
query.workspace = {"_ref" => "https://rally1.rallydev.com/slm/webservice/v2.0/workspace/1111" } 
query.project = {"_ref" => "https://rally1.rallydev.com/slm/webservice/v2.0/project/22222" } #use valid OIDs
query.query_string = "(Name = \"my feature\")"


results = @rally.find(query)
features = [];

results.each do |f|
     f.read
     puts "Current state of Feature #{f["FormattedID"]}: #{f["State"].to_s}"
     features << f
end


features.each do |f|
    field_updates={"State" => state_hash["Developing"]}
    f.update(field_updates)
    puts "Feature #{f["FormattedID"]} is now in State: #{f["State"].to_s}"
end


来源:https://stackoverflow.com/questions/17726215/rally-ruby-toolkit-how-to-get-url-of-portfolio-items-state

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!