Export secret file to Gitlab pipeline
1 min readJul 9, 2017
1. Export file with base64 encoding
Use this command to convert file to base64 and copy result to clipboard
cat myfile.txt | base64
2. Add environment variable to Gitlab project
Copy result and insert it to Gitlab project settings
(Your project → Settings → CI/CD → Environment variables)
3. Create file in pipeline
In .gitlab-ci.yml file add command to create file from environment variable.
echo $MYFILE | base64 -d > /any/path/myfile.txt
Directory where you want to save file must exist, if not you can create it with mkdir -p, -p = parents, it creates all directories.
mkdir -p /any/path && echo $MYFILE | base64 -d > /any/path/myfile.txt
The result file is absolutely same as first one in your computer, you can check it with a command sha1sum myfile.txt