firecow / gitlab-ci-local

Tired of pushing to test your .gitlab-ci.yml?
MIT License
2.37k stars 134 forks source link

Different behaviour for variable expansion? #1070

Closed Minipada closed 10 months ago

Minipada commented 10 months ago

Minimal .gitlab-ci.yml illustrating the issue

---
job:
  script:
   - 'REPOSITORIES=$(wget -O- -q --header "PRIVATE-TOKEN: $MY_TOKEN" "https://gitlab.com/api/v4/projects/ORG%2FPROJECT/registry/repositories")'

Expected behavior Be able to do the operation.

Unfortunately, it returns wget: server returned error: HTTP/1.1 404 Not Found. If i replace $MY_TOKEN by hardcoding the token itself, it works fine.

I also tried removing the single quotes:

---
job:
  script:
   - |
      REPOSITORIES=$(wget -O- -q --header "PRIVATE-TOKEN: $MY_TOKEN" "https://gitlab.com/api/v4/projects/ORG%2FPROJECT/registry/repositories")

But I get the same result

Host information Debian 12 (Bookworm) gitlab-ci-local 4.45.2

Containerd binary Using docker, container running based on docker:20.10.16

Additional context

.gitlab-ci-local-env

PRIVILEGED=true
ULIMIT=8000:16000
VOLUME=certs:/certs/client
VARIABLE="DOCKER_TLS_CERTDIR=/certs"
firecow commented 10 months ago

Where do you specify the MY_TOKEN variable ?

Minipada commented 10 months ago

I'm sorry if I made you lose some time, I needed to add it to .gitlab-ci-local-variables.yml, then it worked fine. Thanks for the quick reply!