1

I would like to receive some help on how I could create some environment variables to be used in README.md within a locally hosted Gitlab instance.

I need two variables to be replaced in README.md when someone accesses the web interface, variables that define the name of the repo and the name of the branch. Any idea is welcome.

Thanks!

torek
  • 448,244
  • 59
  • 642
  • 775
F.Hazi
  • 23
  • 2

1 Answers1

1

I don't think you can use these variables inside a GitLab readme. There is a feature request for this but it isn't implemented yet.

A way around this is to use the predefined variables that are present in GitLab. However, these variables are accessible to GitLab's CI pipelines, and not to any readme files. But perhaps you can find a solution in this answer. It suggests that you keep a placeholder in your readme file, then have a job run that switches out the readme's placeholder with the required value using the sed command. Since the job will have access to both the readme file and the variables, this should work.

M B
  • 2,700
  • 2
  • 15
  • 20