Request for Assistance with gitlab-runner exec and CI/CD Variables

I hope this message finds you well. I am currently facing an issue while using the gitlab-runner exec command locally, specifically in relation to fetching CI/CD variables from the GitLab server.

Description of the Problem:

I have a GitLab CI/CD pipeline with a job (preprod_deploy) that relies on CI/CD variables defined in the GitLab project’s CI/CD settings. When I run this job directly from the GitLab interface, the variables are correctly exposed to the pipeline. However, when I use gitlab-runner exec docker preprod_deploy locally, these variables are not automatically fetched and exposed to my local pipeline.

Question:

Is there a recommended or standard approach to fetch CI/CD variables from the GitLab server when using gitlab-runner exec locally? I want to ensure that my local testing environment accurately reflects the variables used in the GitLab CI/CD pipeline.

Additional Information:

  • I have considered using environment variables in the .gitlab-ci.yml file, but I would prefer to fetch them dynamically from the GitLab server for consistency.
  • I am aware of the --env and --env-file options in the gitlab-runner exec command but would like to avoid manual handling of variables if possible.

Any guidance or suggestions you can provide would be greatly appreciated.

Thank you for your assistance!