firecow / gitlab-ci-local

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

GCL_VARIABLE multiple key/value pairs not working #992

Open thoefkens opened 1 year ago

thoefkens commented 1 year ago

Minimal .gitlab-ci.yml illustrating the issue

.terraform-format:
  stage: terraform-validate
  script:
    - terraform init
    - terraform fmt -check -diff -recursive

Expected behavior When I run gitlab-ci-local, Terraform fails to initialise against an AWS S3 backend (bucket). Normally this works fine when AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are set correctly as env vars. (or in Gitlab itself in the CI CD Variables section). I have tried setting them in GLC_VARIABLES but that has no effect.

Host information MacOS gitlab-ci-local 4.43.0

Containerd binary Docker

BTW Works fine when I put them into .gitlab-ci-local-variables but would like to use ENV VAR GLC_VARIABLES as I work with dotenv a lot so I would not need to define them in different locations.

firecow commented 1 year ago

"I have tried setting them in GLC_VARIABLES but that has no effect"

Show us how you tried using GCL_VARIABLE

thoefkens commented 1 year ago

I use a .envrc file where all environment variables get exported automatically once I go into my folder (where I run gitlab-ci-local).

export AWS_ACCESS_KEY_ID=xxxx
export AWS_SECRET_ACCESS_KEY=xxxx
export GLC_VARIABLES="AWS_ACCESS_KEY_ID=xxx AWS_SECRET_ACCESS_KEY=xxx"
firecow commented 1 year ago
gitlab-ci-local --variable

It's called GCL_VARIABLE

thoefkens commented 1 year ago

Oh my bad... Thank you!

thoefkens commented 1 year ago

Actually @firecow , it still does not work. I tried "GCL_VARIABLE" as you said, that does not work. I then tried "GCL_VARIABLES" and when I set that, and run gitlab-ci-local, I get the error:

❯ gitlab-ci-local
Unknown argument: variables

BTW, the documentation in the readme is wrong apparently, that is why I put GLC_VARIABLES in the first place because it is described like that there. Thanks Thomas

ecourreges-orange commented 1 year ago

I have the same problem, it looks to me like GCL_VARIABLE supports only one variable, GCL_VARIABLES doesn't exist, but if it did, it would solve the problem when you have more than one variable and need expansion, such as login + password.
Also one way to avoid all this would be to have variable expansion in .gitlab-ci-local-variables.yml for example This would allow to have a proper local setup for everyone, overriding only a couple of user/pass/secret which are per user.

firecow commented 11 months ago

I've fixed the documentation here e96e0ff76a7a9bca2610e9bb7431250c6821e5cc

And yes, that needs fixing, sorry about that, will be fixed in a moment, if I can find the bug. image

I've renamed the issue title, hope thats ok.

firecow commented 11 months ago

Found it, now I just need to come up with a fix.

image

AbdulRashidReshamwala commented 3 months ago

@firecow can we merge the draft pr

firecow commented 3 months ago

@AbdulRashidReshamwala No, its in draft because its not ready yet :smile: