I have a powershell script which uses Invoke-RestMethod to invoke an API to trigger test execution. The test execution has takes about 3 hours. However, powershell script ends after 1Hr 40 Mins.
The powershell scripts is triggered as part of Jenkins Job.
Invoke-RestMethod is as below.
$result = Invoke-RestMethod -Headers $basic -Uri $URI -Body $Body -Method Post -ContentType “application/x-www-form-urlencoded;charset=UTF-8” -TimeoutSec 600
How to have the powershell script run till Inoke-RestMethod gets a response?
I tried calling the powershell script as part of Start-Process with -Wait parameter but it does not help.
$Outfilename = $Env:Outputfile
$proc = Start-Process powershell -argument “C:\scripts\xxxxexecution.ps1” -wait -PassThru -RedirectStandardOutput “Outputfile.txt”
$proc.WaitForExit();
if ($proc.ExitCode -ne 0) {
Write-Host “$_ exited with status code $($proc.ExitCode)”
Get-Content .\Outputfile.txt
Exit 1
}
else {
Write-Host “$_ exited with status code $($proc.ExitCode)”
Get-Content .\Outputfile.txt
Exit 0
}
Any help will be appreciated.