Variable in command




during a build, we are pushing some stuff to S3. To better organize our files, we would like to put them in folders by branch name or commit hash.

Is it possible to use these variables in a command? We are looking for something like this:

- name: "Upload"
  service: s3
  command: "put /path/to/file s3://bucket/{{.Branch}}/{{.CommitID}}/"

I tried running a step like this with Jet and ended up with a folder named {{.CommitID}} in S3, which makes me think I’m doing something wrong. :wink:

Thanks for any feedback!
Jan David


Those variables aren’t available for commands at the moment (but this is something we are looking into).

However, if you can model the step to run via a shell, you can use the available environment variables to achieve this.

- service: busybox
  command: sh -c "echo ${CI_COMMIT_ID}"

Would that be a possible workaround for now?


Yeah, I made it work. But it’s not pretty, since I had to manually overwrite the entrypoint of the container… :worried:

Another thing is that I couldn’t test this locally, since jet neither passes the environment variable through nor sets it by itself. I tried both jet steps and CI_COMMIT_ID=test jet steps and both times a folder without a name was created for me on S3…


You can pass in those variables via CLI flags like jet steps --branch "master" --commit_id "aabbccdd". Each environment variable is connected to a flag with the same name, but the CI_ omitted.