3

I have read GitLab's Use CI/CD Variables to Define Artifact Name documentation and examples. In the following excerpt of my .gitlab-ci.yml file, I try to replicate their powershell example:

artifacts:
  name: "$env:CI_JOB_STAGE-$env:CI_COMMIT_REF_NAME"
  expire_in: 1 week
  paths:
    - My\Hardcoded\Path\*

But when I download the artifact, it's named: _env_CI_JOB_STAGE-_env_CI_COMMIT_REF_NAME.zip. I wanted to use a variable for my artifact path, but that didn't work either, so I was forced to hardcode it. What am I doing wrong?

I'm familiar with the open GitLab issue: Artifacts Filename Cannot Be Set with Dynamic Variables, and I would eventually like to put a date & timestamp in the artifact name, but first I'd just like to get any variable working.

I'm using GitLab v15.1.1-ee. My runner is v15.1.1, installed in Windows and uses a shell executor in powershell.

Shawn
  • 172
  • 9
  • 1
    GitLab is not PowerShell, you don't need the `env:` prefix. `"$CI_JOB_STAGE-$CI_COMMIT_REF_NAME"` should do – Mathias R. Jessen Jul 05 '22 at 12:41
  • @MathiasR.Jessen in my runner’s config.toml, my executor=“powershell”. I also tested the other examples from the doc, including your suggestion, but it did not work. – Shawn Jul 06 '22 at 19:28
  • correction: in my `config.toml` I have `executor = "shell"` and `shell = "powershell"` – Shawn Jul 07 '22 at 14:25
  • 1
    This is most likely a bug in GitLab: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/29141 – Ville Laurikari Jul 14 '22 at 08:49

1 Answers1

0

Per Ville Laurikari's comment, it appears this was a bug affecting v15.1.1. Today, I noticed that our GitLab instance was upgraded to v15.1.2-ee, and I replaced my runner with v15.1.0. The variables now work as documented.

Shawn
  • 172
  • 9