$FX_USER=$args[0]
$FX_PWD=$args[1]
$FX_JOBID=$args[2]
$REGION=$args[3]
$TAGS=$args[4]
$SUITES=$args[5]
$CATEGORIES=$args[6]
$FX_HOST=$args[7]
$taskStatus="WAITING"
Write-Host "taskStatus = " $taskStatus
while ( ("$taskStatus" -eq "WAITING") -or ("$taskStatus" -eq "PROCESSING") )
{
sleep 5
Write-Host "Checking Status...."
$passPercent=$(curl -k --header "Content-Type: application/json;charset=UTF-8" -X GET -u ""${FX_USER}":"${FX_PWD}"" ""${FX_HOST}"/api/v1/runs/${runId}" | jq -r '."data"|.ciCdStatus')
$array = $passPercent | ConvertFrom-Json
$taskStatus="${array[0]}"
Write-Host "task-status= $taskStatus"
Write-Host "Status =" "${array[0]}" " Success Percent =" "${array[1]}" " Total Tests =" "${array[2]}" " Time Taken =" "${array[4]}" " Run =" "${array[5]}"
當我執行 powershell 的這段程式碼時,我從控制台輸出中收到以下錯誤。
ConvertFrom-Json:無效的 JSON 原語:等待。在 C:\Users\Administrator\test.ps1:57 char:45 + $array = $passPercent | ConvertFrom-Json + ~~~~~~~~~~~~~~~~ + CategoryInfo:未指定:(:) [ConvertFrom-Json],ArgumentException + FullQualifiedErrorId:System.ArgumentException,Microsoft.PowerShell.Commands.ConvertFromJsonCommand
狀態 = 成功百分比 = 測試總數 = 花費的時間 = 運行 =
我應該在 = 登入上面的欄位(例如 Status= Completed)後獲得字串或整數中的一些值,任何人都可以幫我解決緊急情況。謝謝