-
Notifications
You must be signed in to change notification settings - Fork 1
/
copy-env-var.sh
executable file
·36 lines (31 loc) · 1.43 KB
/
copy-env-var.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#
# Circle CI & gradle.properties live in harmony
#
# Android convention is to store your API keys in a local, non-versioned
# gradle.properties file. Circle CI doesn't allow users to upload pre-populated
# gradle.properties files to store this secret information, but instaed allows
# users to store such information as environment variables.
#
# This script creates a local gradle.properties file on current the Circle CI
# instance. It then reads environment variable TEST_API_KEY_ENV_VAR which a user
# has defined in their Circle CI project settings environment variables, and
# writes this value to the Circle CI instance's gradle.properties file.
#
# You must execute this script via your circle.yml as a pre-process dependency,
# so your gradle build process has access to all variables.
#
# dependencies:
# pre:
# - source environmentSetup.sh && copyEnvVarsToGradleProperties
#!/usr/bin/env bash
GRADLE_PROPERTIES=$HOME"/.gradle/gradle.properties"
export GRADLE_PROPERTIES
echo "Gradle Properties should exist at $GRADLE_PROPERTIES"
if [ ! -f "$GRADLE_PROPERTIES" ]; then
echo "Gradle Properties does not exist"
echo "Creating Gradle Properties file..."
touch $GRADLE_PROPERTIES
echo "Writing GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET to gradle.properties..."
echo "GITHUB_CLIENT_ID=$GITHUB_CLIENT_ID" >> $GRADLE_PROPERTIES
echo "GITHUB_CLIENT_SECRET=$GITHUB_CLIENT_SECRET" >> $GRADLE_PROPERTIES
fi