'How to do polling for REST endpoint on Jenkins?
On the Jenkins pipeline that I've created, I make a POST curl request once. However, since this job goes into a queue first, I need to wait till the job is completed. This is an example of my command
curl -X POST -H "Content-Type: application/json" \
-d '{"source_path": "source/path/example", "destination_path": "destination/path/example"}' \
http://example.com/v1/postJob
This returns a JSON response {"jobID": 1234}
I want the Jenkins job to stay in 'running' state till the GET endpoint returns "status": success. The GET endpoint returns a JSON body with a field 'status' that indicates whether the job is done. This is the GET endpoint
curl http://example.com/v1/jobs/1234
This returns a JSON response
{
"job": 1234,
"status": success
}
Can anyone provide me with an example of polling that can be implemented directly on Jenkins without using a Jenkinsfile?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
