How do you pass an artifact to a build step that runs a plugin?

My pipeline.yml looks like this:

- label: ":Step1"
  plugins:
    - ssh://.../docker-compose-buildkite-plugin.git#v3.5.1:
        config:
          - tools/sonarqube/docker-compose.yaml
        run: generateCsv
  key: "sonarqube"
  agents:
    queue: "sonarqube"
  artifact_paths: stats.csv
- wait
- label: "step2"
  // want to download stats.csv here before running the plugin
  plugins:
    - ssh://.../cqs-importer-buildkite-plugin.git#v0.9.5:
        csv_file: "stats.csv"
  agents:
    queue: java

Hi @kenyee!

Welcome to the community! :wave:

Assuming your plugin uses a command hook, any plugin (or hook) that runs before the command hook, should allow you to download an artifact for use in the step.
We have for example this plugin that does that as a pre-command hook: artifacts-buildkite-plugin/hooks at master · buildkite-plugins/artifacts-buildkite-plugin · GitHub

Hope this helps!

Cheers

Hi Paula,

Thanks for the reply.
Is there any way to do this via a pipeline.yml directly?
Sounds like the answer is no?
Essentially, what I want is the opposite of “artifact_paths” in a buildstep.

e.g.,

  • label: “step2”
    download_artifacts:
    name: stats.csv
    location: “.”

Hey!

Oh, right … hmm :thinking:, unfortunately, that particular functionality is not available; you can only automatically upload artifacts (artifact_paths) but to download them you have to use the command in your build scripts buildkite-agent artifact download
You do make a good suggestion though. I’m going to pass this info to our Product team.

Thanks!

Thanks for confirming and really hope to get that feature in the pipeline.yml someday soon :slight_smile:

I’ll add the download call into my plugin.

1 Like

Using the artifacts_path notation is basically a shorthand for using the artifacts plugin.

- label: ":Step1"
  plugins:
    - ssh://.../docker-compose-buildkite-plugin.git#v3.5.1:
        config:
          - tools/sonarqube/docker-compose.yaml
        run: generateCsv
  key: "sonarqube"
  agents:
    queue: "sonarqube"
  artifact_paths: stats.csv

Your step above, can also be written as:

- label: ":Step1"
  plugins:
    - ssh://.../docker-compose-buildkite-plugin.git#v3.5.1:
        config:
          - tools/sonarqube/docker-compose.yaml
        run: generateCsv
    - artifacts#v1.3.0:
        upload: stats.csv
  key: "sonarqube"
  agents:
    queue: "sonarqube"

When you consider that artifacts can be managed via a plugin, and that plugins are processed in order, you should be able to get your artifact to the second step, like this:

- label: "step2"
  // want to download stats.csv here before running the plugin
  plugins:
    - artifacts#v1.3.0:
        download: stats.csv
    - ssh://.../cqs-importer-buildkite-plugin.git#v0.9.5:
        csv_file: "stats.csv"
  agents:
    queue: java
2 Likes