Runtime interpolation of environment variable followed by underscore

I would like to do runtime interpolation of an environment variable (JOB_NAME) into a string, but have it followed by an underscore. I can’t use ${JOB_NAME}_xxx as that will get evaluated at pipeline upload time. If I try to escape the $, i get an error:

artifact_paths: "output/\${JOB_NAME}_artifacts/*"

gives

2023-11-08 09:29:45 FATAL  Pipeline parsing of "pipeline.yml" failed (Failed to parse pipeline.yml: line 73: found unknown escape character)
🚨 Error: The command exited with status 1

Hey @simonbyrne

Thanks for the message.

I reproduced this on my end and was able to get around the pipeline parse error by using $$ instead of /$ for the variable interpolation.

An example of a runtime interpolation of the env var JOB_NAME in the context of a pipeline upload as seen below

Example

env:
 JOB_NAME: "sample-job"
  
steps:
 - label: "Generating Artifact Upload step"
    command: |
      cat <<- YAML | buildkite-agent pipeline upload 
        steps:
          - label: "Upload Artifact"
            command: "echo Upload Artifact"
            artifact_paths: "output/$${JOB_NAME}_artifacts/*"  
      YAML

Cheers!