Store credentials in Gitlab CI/CD that are currently in a JSON structure

I have credentials for the Firebase Firestore product. I currently use it as is, simply pass in a JSON file and they authenticate. Example of the structure below

“type”: “string”,
“project_id”: “name-numbers”,
“private_key_id”: “string of numbers and letters”,
“private_key”: “-----BEGIN PRIVATE KEY-----\nGENERIC PRIVATE KEY\n-----END PRIVATE KEY-----\n”,
“client_email”: “string”,
“client_id”: “string of numbers”,
“auth_uri”: “string uri”,
“token_uri”: “string uri”,
“auth_provider_x509_cert_url”: “string uri”,
“client_x509_cert_url”: “string uri”

I currently run a dockerized CI/CD pipeline.

I would like to store the above example under the variables section.

How can I go about doing this?

I haven’t been successful with the following attempts:

  • storing it as a variable and passing it into my docker image at build stage via --build-args
  • storing it as a file and trying to use it within my docker image at build stage
  • storing it as a file, trying to cat out the content into a variable and passing that to my docker image via --build-args
  • storing each key / value pair as their own variables and attempting to access them, certain ones do not work

Do not put any PRIVATE KEY into Git or Docker image. Put it right into running container through volume mappings or some analogical features.
Gitlab supports variables that are passed to entrypoint session and event could be written as the file.

1 Like