我正在使用System Center Orchestrator和Powershell爲JIRA設置自動化進程。在這個例子中,我已經有了來自JIRA Rest API的原始JSON數據。使用Powershell從JIRA Rest API解析問題密鑰
function ConvertFrom-Json20([object] $item){
add-type -assembly system.web.extensions
$ps_js=new-object system.web.script.serialization.javascriptSerializer
#The comma operator is the array construction operator in PowerShell
return ,$ps_js.DeserializeObject($item)
}
[object]$JSON = '{Raw JSON Data from JIRA Variable}'
$results = ConvertFrom-Json20($JSON)
$key = @()
$count = @()
foreach($issue in $results.issues) {
$key += $issue.key
$count += $key.count
}
$key = @($key | Where-Object {$_ -ne $null})
$count = @($count | Where-Object {$_ -ne $null})
我使用不具備最新的PowerShell的包所以這就是爲什麼我已經包括ConvertFrom-Json20([object])
功能的服務器。在SCORCH中,$key
和$count
是發佈的數據變量。