Where to store Android KeyStore file for CirlceCi build?

I am trying to set up a continuous integration build for my android app. For this I am using the CircleCi platform. I now store my Keystore.jks application files locally, but CircleCi needs this to sign my application. How can I achieve this without having to save the file to my git repository? Or maybe I shouldn't worry about this as long as the repository is private?

My gradle signatures:

signingConfigs {
    if (System.getenv("CIRCLECI")) {
        release {
            keyAlias '****'
            keyPassword '****'
            storeFile file(System.getenv("******"))
            storePassword '****'
        }
    }else{
        release {
             ...
        }
    }
}

      

My .yml circle:

general:
    artifacts:
        - /home/ubuntu/my-app/app/build/outputs/apk/
machine:
  environment:
    ANDROID_HOME: /usr/local/android-sdk-linux
dependencies:
  override:
     - chmod +x gradlew
test:
  override:
    - ./gradlew assemble

      

I tried to save the keystore file in CircleCi as an environment variable, but it doesn't work, my build failed with an error:

> Execution failed for task ':app:validateSigningDemoRelease'.
> > Keystore file /home/ubuntu/my-app/app/  HERE_IS_THE_KEYSTORE not found for signing config 'release'.

      

Unsigned and debug builds succeed.

I can also use any other ci platform if you suggest something else.

Thanks for every tip!

+3


source to share


2 answers


For me, you have two solutions:

  • This is a private vault and you are the only one using it, so you can press a key.

  • My preferred solution would be to create another key which you call circleCI (for example) and which you press. I personally use this solution



My build.gradle

signingConfigs {
        Keys {
            keyAlias 'mykey'
            storeFile file('../private_key/upload_key.jks')
            keyPassword ''
            storePassword ''
        }

        Circleci {
            keyAlias 'key'
            storeFile file('../private_key/debug_key.jks')
            keyPassword ''
            storePassword ''
        }
    }
buildTypes {
        release {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                    'proguard-rules.pro'
            signingConfig signingConfigs.Keys
        }
        debug {
            signingConfig signingConfigs.Keys
        }
        circleci{
            signingConfig signingConfigs.Circleci
        }
    }

      

0


source


I recently ran into this problem and decided that the simplest solution was to encode the keystore file to base64 and include it in an environment variable in CircleCI.

This will encode the file and you can copy and paste the value via:

openssl base64 -A -in .signing/release.jks 

      



Then, in your config.yml file in CircleCI, decode it back:

echo $RELEASE_KEYSTORE_BASE64 | base64 -d > .signing/release.jks

      

0


source







All Articles