Can't make `buildkite-agent pipeline upload` work on my machine

Hello,

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?

Thanks for your help

Hey @zenogueira :waving_hand:,

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.

So you would not be able to run this outside a Buildkite job. If you want to validate the pipeline yaml then you can use GitHub - buildkite/pipeline-schema: A JSON schema for Buildkite’s pipeline file format

Please let us know if you have any questions.

Thanks,
Suma

ok, thanks for explaining.

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).

Is there a way to do it?

I’m not trying to validate the pipeline schema.

Hey @zenogueira :waving_hand:

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.

Cheers

I’m not sure what “checkout” means.

And can it be done with the API? Which API?

Also: I don’t necessarily need to create the jobs on my local agent, I could push the build to a cluster.

I’m trying to understand if it’s possible to create pipelines or builds from my machine/a host

Hey @zenogueira :wave:,

Yes, you can create pipelines and builds from your local machine, as long as you have a valid API token and the necessary permissions.

Here are the options using the REST API

ok, got it.

Thanks for the reply :folded_hands:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.