這裏是您可以自定義,使預提交鉤子調用它,看看這個故事在工作區
實際存在由於它基於Rally REST toolkit for Ruby一個Ruby腳本示例被寫入,它需要一個命令行參數來運行,例如
紅寶石find_story.rb US123
require 'rally_api'
headers = RallyAPI::CustomHttpHeader.new()
headers.name = "find story"
headers.vendor = "Nick M RallyLab"
headers.version = "1.0"
config = {:base_url => "https://rally1.rallydev.com/slm"}
config[:api_key] = "_abc123"
config[:workspace] = "W1"
config[:project] = "Sample Project"
config[:version] = "v2.0"
config[:headers] = headers #from RallyAPI::CustomHttpHeader.new()
unless ARGV.length == 1
puts "enter one argument, e.g. US123, with no spaces"
exit
end
story = nil
story_id = ARGV[0]
puts "find story by FormattedID: #{story_id}"
@rally = RallyAPI::RallyRestJson.new(config)
query = RallyAPI::RallyQuery.new()
query.type = :story
query.fetch = "Name,FormattedID,ScheduleState"
query.workspace = {"_ref" => "https://rally1.rallydev.com/slm/webservice/v2.0/workspace/111" }
query.query_string = "(FormattedID = \"#{story_id}\")"
result = @rally.find(query)
if(result.length > 0)
puts "found the story"
story = result.first
puts "FormattedID: #{story["FormattedID"]}, Name: #{story["Name"]}, ScheduleState: #{story["ScheduleState"]}"
else
puts "did not find a story with FormattedID #{story_id}"
end
該工具包提供了一個語法糖,但下面有hierarchicalrequirement
端點通過FormattedID
(FormattedID = US123)
查詢,其中1111應的對象ID來代替你的工作區在/workspace/1111
:
https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement?workspace=https://rally1.rallydev.com/slm/webservice/v2.0/workspace/1111&query=(FormattedID%20%3D%20US123)&start=1&pagesize=20
您可以直接在瀏覽器中測試此URL。如果您當前未在同一瀏覽器的另一個選項卡中登錄到Rally,系統會提示您登錄。
你能否請告知如何解決這個問題? – user3301494 2014-10-15 08:26:03
在WS API中,查詢(FormattedID = US2918xyz)將返回0個結果,並且不會返回錯誤。您可以通過使用regexp添加驗證所有可能的無效格式來擴展上面的代碼http://www.ruby-doc.org/core-2.1.3/Regexp.html – nickm 2014-10-15 16:54:05
嗨,它返回US2918xyz和US2918的結果。這兩種情況下的JSON結果沒有什麼區別..這就是我感到驚訝的原因..可能是一個錯誤? – user3301494 2014-10-17 09:56:15