Skip to main content

Downloading a keystore file

Abstract

You can define the location of the keystore file of an Android app in your build.gradle file. If the keystore file itself is missing from the location, you can use one of our file downloading Steps to download the keystore file from Bitrise and put it in the defined location.

A keystore file is required for Android code signing. You can define the location of the keystore file of an Android app in your build.gradle file. If the keystore file itself is missing from the location, you can use one of our file downloading Steps to download the keystore file from Bitrise and put it in the defined location.

Bitrise has two Steps which download files from the Code Signing tab. Which one to use in your workflow depends on where you uploaded your keystore file in the Code Signing tab:

  • File Downloader Step: If you have uploaded your keystore file to the ANDROID KEYSTORE FILE section, which is the recommended place for your keystore file, this is the Step you should use. Once the file is uploaded, Bitrise assigns an Environment Variable (BITRISEIO_ANDROID_KEYSTORE_URL) to the download URL (which is a time-limited, read-only download URL) of the file as the value.

    Downloading a keystore file
  • Generic File Storage Step: If you have uploaded your keystore file to the GENERIC FILE STORAGE section on the Code Signing tab, this is the Step you should use. Bitrise assigns an Environment Variable ($GENERIC_FILE_STORAGE) to the download URL (which is a time-limited, read-only download URL) of the file as the value. If you use an Environment Variable in your build.gradle file, you can use a Script Step to overwrite the Environment Variable’s value with the destination path defined in the $GENERIC_FILE_STORAGE Environment Variable. Make sure you use envman and not just a simple export.

    Downloading a keystore file
  1. Add either the File Downloader or the Generic File Storage Step to your workflow. The Step should be added BEFORE the Gradle Runner Step.

  2. If you use the File Downloader Step, fill out the following 2 input fields:

    • Download source url: Set the generated keystore URL you get when you upload your file to the ANDROID KEYSTORE FILE section of the Code Signing tab).

    • Download destination path: Set the location of the keystore file as a relative path. This path should be the same as the keystore path already defined in your build.gradle file (for example, $HOME/keystores/project_release.keystore).

  3. Add the Gradle Runner Step right after your file downloading Step.

With that said, if you have successfully added the Steps to download your keystore file to the same location that you specified in your build.gradle file, you do not need the Android Sign Step in your workflow. Our Gradle Runner Step will sign and assemble your project.