如何通过变更集从Builds到Artifacts进行遍历?

时间:2013-07-09 20:38:27

标签: ruby rally

我可以在我的抓取中包含变更集:

query.type = :build 
query.fetch = "Status,Uri,Changesets"

但我不知道如何阅读更改以获取与它们相关的工件。根据API文档,Changesets集合不可查询。

1 个答案:

答案 0 :(得分:0)

当您获得Builds结果时,您可以迭代两个集合:每个Changeset上的每个Build和Artifact上的Changeset。这是一个使用rally_api gem的Ruby代码,它打印出相关工件的FormattedID:

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

query = RallyAPI::RallyQuery.new()
query.type = :build
query.fetch = "Status,Uri,Changesets,Changeset,Revision,Artifacts,FormattedID"
query.workspace = {"_ref" => "https://rally1.rallydev.com/slm/webservice/1.43/workspace/1111.js" }  #use valid OID
query.project = {"_ref" => "https://rally1.rallydev.com/slm/webservice/1.43/project/2222.js" }          #use valid OID
query.query_string = "(ObjectID = 3333)"     #use valid OID

results = @rally.find(query)

change_sets = []
artifacts = []

results.each do |b|
    b.read
    puts "Status: #{b["Status"]}, Uri: #{b["Uri"]}"

    b["Changesets"].each do |c|
        c.read
        puts "Revision: #{c["Revision"]}"
        change_sets<<c
    end
end

change_sets.each do |c|
    if (c["Artifacts"])
        c["Artifacts"].each do |a|
            a.read
            puts "FID: #{a["FormattedID"]}"
            artifacts<<a
        end
    end
end