firecow / gitlab-ci-local

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

Unable to source global variables #1208

Closed heydonovan closed 1 month ago

heydonovan commented 2 months ago

Minimal .gitlab-ci.yml illustrating the issue

---
x:
  stage: build
  script:
    - echo $FOO
    - env | grep FOO
y:
  stage: build
  script:
    - mkdir ~/.aws/ # necessary for `ls: cannot access '/root/.aws/': No such file or directory` error
    - ls -lah ~/.aws/

Expected behavior

$ gitlab-ci-local
parsing and downloads finished in 58 ms
x starting shell (build)
x $ echo $FOO
x >
x $ env | grep FOO
x finished in 28 ms  FAIL 1
$ gitlab-ci-local --manual 'y'
parsing and downloads finished in 38 ms
y starting registry.company.com/image:main (build)
y copied to docker volumes in 541 ms
y $ mkdir ~/.aws/
y $ ls -lah ~/.aws/
y > total 12K
y > drwxr-xr-x 2 root root 4.0K May  8 21:46 .
y > drwxrwx--- 1 root root 4.0K May  8 21:46 ..
$ cat ~/.gitlab-ci-local/.env
FOO="BAR"
$ cat ~/.gitlab-ci-local/variables.yml
global:
  FOO: "BAR" # <- this does work btw
  VOLUME: "$HOME/.aws/:$HOME/.aws/" # this only works via cli

Host information macOS 14.4.1 gitlab-ci-local 4.48.2 Docker version 26.0.0

Containerd binary Docker Desktop

Additional context

Tried using --umask and --privileged as well. Maybe volumes always have to be specified via cli?

heydonovan commented 1 month ago

Figured it out. You can close this!

Updated .env to include VOLUME=$HOME/.aws/:/root/.aws/. $HOME wasn't being expanded on the right side.