我正在使用此函数在Rally中获取Project 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。谢谢!
答案 0 :(得分: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}"