Search code examples
apkgitlab-cipipelinegitlab-ci-runner

How to put a file (.jks, .p12) as variable?


I'm working on a gitlab-ci pipeline to automate build, sign "apk" and deploy to the play store. The pipeline work fine but the two files ".jks" to sign the "apk" and the ".p12" for my Google cloud platform service are now in my repository and it's not a secure way to do it. What I want to do is to put this two files ".jks and .p12" as a gitlab-ci variable to avoid putting this files in my repo...


Solution

  • Yes you could define gitlab ci variable of file type

    here is the doc for gitlab ce :

    https://docs.gitlab.com/ee/ci/variables/#use-file-type-cicd-variables

    In the settings of your project, you will need to define a variable (file type).

    Then gitlab will create a temporary file for this variable with your file content.

    You could use it directly or use cp command like this:

    cp $MY_SECRET_FILE $HOME/.m2/settings.xml
    

    edit: binary files seems not supported, so follow and upvote following issue : https://gitlab.com/gitlab-org/gitlab/-/issues/205379