【问题标题】:Rally Ruby toolkit: how to get URL of Portfolio Item's state?Rally Ruby 工具包:如何​​获取投资组合项目状态的 URL?
【发布时间】:2013-07-18 14:24:03
【问题描述】:

在 Ruby 中是否有使用 rally_api 的示例如何设置 here 中提到的功能状态?

具体来说,有没有办法查询 ObjectID 或使用状态的完全限定路径

"State" => "Developing"

而不是

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

【问题讨论】:

    标签: ruby rally


    【解决方案1】:

    可以查询State,创建一个hash,用查询结果填充hash,其中State Name是key,State_ref是value:

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

    然后我们可以更新一个状态:

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

    这是一个代码示例:

    @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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-11-10
      • 1970-01-01
      • 2020-07-06
      • 1970-01-01
      • 1970-01-01
      • 2011-02-25
      • 1970-01-01
      相关资源
      最近更新 更多