Artifacts in annotations: specify step or build id

In `buildkite-agent annotate` v3 | Buildkite Documentation, it is mentioned that you can embed artifacts using an artifact:// prefix. Is there a mechanism to specify the step id (e.g. if I have artifacts with the same name across jobs), or build id (so I can refer to artifacts from previous builds)

Hey @simonbyrne!

You can embed environment variable values in the annotation output, so for example:

steps:
  - label: ":console: Annotation Test"
    command: |
      buildkite-agent artifact upload "indy.jpg"
      cat << EOF | buildkite-agent annotate --style "info"
        <img src="artifact://indy.jpg" height=250 >
        <p>From $$BUILDKITE_STEP_ID</p>
      EOF

Will produce the following annotation:

You could also use a variable that produces slightly more readable results, such as BUILDKITE_LABEL, which would give the name of the step.

Does that help at all?

Cheers,

Ben

Not quite: I meant does artifact:// support query parameters for step or build (like the artifact download command).

In the first case, what I meant was that suppose I have multiple steps, each of which upload an artifact plot.png. How can I refer to the plot.png from each step? e.g.

<img src="artifact://plot.png?step=step1" height=250 > # plot.png from step1
<img src="artifact://plot.png?step=step2" height=250 > # plot.png from step2

In the second case, I’d like to embed to the plot.png from a previous build alongside the plot.png from the current one:

<img src="artifact://plot.png?build=prev_build_id" height=250 > # plot.png from previous build
<img src="artifact://plot.png" height=250 > # plot.png from current build

In this case, I don’t think that’s possible with the artifact:// path, but does seem possible using the buildkite-agent download method, where you can define a step and build.

Cheers,

Ben