'Can Circle CI reference gradle.properties credentials?
I am setting up a Circle CI build for an Android project, and am wondering how to add a gradle.properties file to my project build. I use a local gradle.properties to store my API keys and sensitive data. Other CI tools (ie, Jenkins) allow you to upload a gradle.properties file to use across all builds, but I am not able to find a way to do this in Circle CI.
It seems that environment variables are the only way Circle CI allows you to add secret credentials to your project.
Is there a way to use credentials from gradle.properties on Circle CI builds?
Solution 1:[1]
Add all properties in the gradle.properties to CircleCI "Environment Variables", but prepend them with:
ORG_GRADLE_PROJECT_
Solution 2:[2]
Depending on your environment(s), you could also use base64 to encode/decode gradle.properties. This worked for me on my macOS CircleCI environment:
From my local macOS computer, I encoded my multi-line
gradle.propertiesfile using:base64 < gradle.properties > encoded-gradle.propertiesI copied the value in
encoded-gradle.propertiesand placed it in a CircleCI environment variable (in this case, named the variable:GRADLE_PROPERTIES_DATA)
In my CircleCI config.yaml file, before building, created the gradle.properties file and decoded the encoded value and placed it in gradle.properties, using the following:
echo $GRADLE_PROPERTIES_DATA | base64 --decode > gradle.properties
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Stephen Rauch |
| Solution 2 |
