I’m trying to do some tests with the buildkite-agent pipeline upload command locally and can’t make it work. I wanted to interact with my pipelines and agents through the command line, without having to make commits on a repo and pushing them
i have a very simple pipeline.yml:
steps:
- command: "echo \"hello\""
Then I run buildkite-agent pipeline upload pipeline.yml and it get these two errors:
fatal: missing job parameter. Usually this is set in the environment for a Buildkite job via BUILDKITE_JOB_ID.
and
fatal: missing agent-access-token parameter. Usually this is set in the environment for a Buildkite job via BUILDKITE_AGENT_ACCESS_TOKEN.
I’ve checked the /opt/homebrew/etc/buildkite-agent/buildkite-agent.cfg file for the agent access token, and added some random value for the job id (also tried to use running builds ids). But I still get errors:
POST https://agent.buildkite.com/v3/jobs/0195b436-8ed4-46cf-a67c-30bbf20a6b40/pipelines?async=true: 401 Unauthorized: Invalid access token (Attempt 1/60 Retrying in 5s)
I’ve tried creating a new agent token, tried to understand if the agents create new env vars with these values, etc, but nothing fixes it.
I’m not sure how to make it work. Will this command only work if run in the buildkite pipelines jobs?
This is Suma from Buildkite support team. Thank you for reaching out to us with your question.
You cannot run pipeline upload command outside of a running job where the job will use the agent token to get the agent access token. So that is why when you try to run it locally, it gives you the error asking for the job ID and agent access token.
What if i want to create a new build/pipeline and run jobs from a host/from my machine, outside of a buildkite job (but to run a new buildkite job/build/pipeline).
There isn’t a way to run jobs locally at the moment without the API, even with a locally running agent. The scheduler would be needed to assign those jobs even where no checkout is needed.