0

我正在使用此功能在 Rally 中获取项目 ID。

def getProjectID(projectName)
results = @rally.find(RallyAPI::RallyQuery.new({:type => :project, :query_string => "(Name = \"" + projectName + "\")"}))
project = results.first.read
@projectID = project.ObjectID
end

给定标签名称,任何人都可以建议我在这些行中获取标签 ID。谢谢!

4

1 回答 1

0

此代码在按名称查询标签后打印标签的 ObjectID:

require 'rally_api'

#Setup custom app information
headers = RallyAPI::CustomHttpHeader.new()
headers.name = "Find Tag's ObjectID given the Name"
headers.vendor = "Nick M RallyLab"
headers.version = "1.0"

# Connection to Rally
config = {:base_url => "https://rally1.rallydev.com/slm"}
config[:username] = "user@co.com"
config[:password] = "secret"
config[:workspace] = "W"
config[:project] = "P"
config[:version] = "v2.0"
config[:headers] = headers #from RallyAPI::CustomHttpHeader.new()

rally = RallyAPI::RallyRestJson.new(config)

tagQuery = RallyAPI::RallyQuery.new()
tagQuery.type = :tag   #userstory or hierarchical_requirement or hierarchicalrequirement will also work
tagQuery.fetch = "ObjectID"
tagQuery.project = {"_ref" => "https://rally1.rallydev.com/slm/webservice/v2.0/project/2222.js" } 
tagQuery.order = "Name Asc"
tagQuery.query_string = "(Name = \"tag1\")"
tagResults = rally.find(tagQuery)
myTag = tagResults.first
puts "ObjectID: #{myTag.ObjectID}"
于 2013-09-23T16:30:19.950 回答