How call rest api in command step in buildkite?

92 views Asked by At

Here is the rest documentation for buildkite and any request requires a auth token. Can this API be invoked from buildkite build somehow? Maybe some command that already grabbed token because it running inside Buildkite? or some additional step to get such a token?

Ot the only way is to go https://buildkite.com/user/api-access-tokens section and create token manually even when I use buildkite API inside buildkite step?

1

There are 1 answers

0
Narthana Epa On

The REST API uses a different token from the agent when it's running inside a job. If you want to use the REST API from inside a job, you'll have to find a way to retrieve a REST API token in your builds, as it's a secret, you should manage access to it as such (e.g. don't just put it in pipeline's environment variables).

Once you have a job that has access to the REST API token, you can use it to call the REST API with a tool like CURL, or the BK CLI.