I am using Jenkins, in a PowerShell command step, to call a Web API service. I am calling the service using Invoke-WebRequest.
This service call has to be in Jenkins, because I need to do it only if other Jenkins jobs have completed successfully.
The service can run for several hours. If I don't have the TimeoutSec parameter, then the step completes with a timeout, before the Web API has completed. If I have the parameter with a large value, such as 36000, then the Web API completes normally, but the step goes on for 10 hours. The other parameters have no relation to this issue.
I am seeking a good way to have the Jenkins step complete as soon as the Web API completes, not earlier and not later.
try
{
$url = "https://ourserver.com/modules/OurService"
$response = Invoke-WebRequest -Uri $url -UseDefaultCredentials -Method Get -TimeoutSec 36000 -UseBasicParsing
}
catch
{
$err=$_.Exception
Write-Host '-----------------------'
Write-Host $err
Write-Host '-----------------------'
exit -1
}
exit 0