In one of my applications, I want to trigger a Travis CI build, "watch" the build as it is scheduled, run and finishes, then retrieve the final build state and the build log to output it in my app.
I started by triggering a build with the API, which gives me a Request
and its request.id
. This works perfectly.
- Then I can retrieve this
Request
, which includes theRequest.state
and an embeddedBuild
and itsBuild.id
along with theBuild.state
, using the/repo/.../request/#id
endpoint. - I could then start polling
/build/#id
endpoint to monitor the state every second. - As soon as the build is finished, I can use the
Job
that is part of theBuild
(when requested from/build/#id
) to download the log from/job/#id/log
and display it in my application.
This all sounds pretty inefficient.
Is there a better way to achieve this?
Is there a "quicker way" (= less requests) from creating the request
to log
?
Can I avoid the manual polling somehow?