How to add Gitlab custom variable to ASP.NET Project CI/CD

Viewed 438

I'm working on ASP.NET project using Gitlab CI/CD and would like to inject the token that are on my CI/CD Settings>Variables, to my variable in the controller

controller.cs

            var clientId = THE_TOKEN_I_WANT_TO_INJECT1;
            var thumbprint = THE_TOKEN_I_WANT_TO_INJECT1;
            var tenantId = THE_TOKEN_I_WANT_TO_INJECT1;

Please advice, how to add Gitlab environment variable in my ASP.NET project

1 Answers

Steps to try:

  • Set an environment variable in GitLab.
  • Call printenv in your job scripts. Inspect the output to ensure the variable is set and available to your GitLab runner.
  • Add a line to your codebase to read and print the environment variable: https://stackoverflow.com/a/37387589/2675670
Related