GitLab CI allows adding custom variables to a project.
It allows to use a secret variable of type file
where I specify a Key that is the variable name and Value that is the content of a file(e.g. content of certificate)
Then during execution of the pipeline the content will be saved as a temporary file and calling the variable name will return the path to the created file.
Ultimately I need to copy this file to a Docker container that is created when building the project. (docker build ...
in the yml)
When testing if the variable works, I tried echo $VARIABLE
in .gitlab-ci.yml
and it works, returns path of temp file. But when doing RUN echo $VARIABLE
in the Dockerfile
, it is empty. Therefore I also cannot use ADD $VARIABLE /tmp/
which is my goal.
Is there a way to solve this and make this file available to the Dockerfile
? I am new to Docker and GitLab and not sure where else to look.
Had to use .yml file docker build
argument --build-arg VARIABLE_NAME=variable_value
and in Dockerfile use ARG VARIABLE_NAME
so the Dockerfile knows it needs to use variable from environment.