How to insert files as environment variables with Base64

If you need to insert sensitive text-based documents or even small binary files into your project in secret it is possible to insert them as an environment variable by leveraging base64 encoding.

Base64 is an encoding scheme to translate binary data into text strings. These values can be inserted as an environment variable and decoded at runtime.

Screen_Shot_2018-04-25_at_8.54.09_AM.png

 

You can encode a file via your command line terminal by feeding it directly to base64.

base64 [option] [file]

Here is the MAN documentation for base64.

 

To then decode the base64 file from within your container you can run the decode option.

base64 --decode [file]

 

This article is derived from this documents page: https://circleci.com/docs/1.0/google-auth/

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.