2013-09-23 37 views
0

我使用這個函數來獲取項目ID的拉力賽。獲取標記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

此代碼打印標籤的對象ID後,通過查詢名稱標籤:

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] = "[email protected]" 
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}"