2

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

2
  • Have you tried something like Environment.GetEnvironmentVariable? Commented Apr 14, 2022 at 21:18
  • Tried it, can't retrieve the variable unfortunately. I have a pipeline that get the variable from Gitlab. But couldn't find a way to get it inside ASP.NET Commented Apr 15, 2022 at 13:56

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.