Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit a161f15

Browse files
Gunasekar KGunasekar K
authored andcommitted
Migrating to properties files to S3
1 parent 4665d09 commit a161f15

File tree

4 files changed

+115
-31
lines changed

4 files changed

+115
-31
lines changed

.circleci/config.yml

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,14 @@ jobs:
2424
wget http://downloads.sourceforge.net/project/jboss/JBoss/JBoss-4.2.3.GA/jboss-4.2.3.GA-jdk6.zip
2525
unzip jboss-4.2.3.GA-jdk6.zip
2626
cd project
27-
- run:
28-
name: checking out build repo
29-
command: |
30-
git clone --branch master https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
31-
#git clone --branch master git@github.com:appirio-tech/ops.git ../direct-config-update
32-
#git clone --branch master https://$GITUSER:$GITPASSWD@github.com/appirio-tech/ops ../direct-config-update
3327
- checkout
34-
- run:
35-
name: copying configuration file
36-
command: |
37-
cp ./../buildscript/direct/conf/dev/token.properties.enc .
38-
openssl enc -aes-256-cbc -d -in token.properties.enc -out token.properties -k $SECPASSWD
3928
- run:
4029
name: Installation of build dependencies.
4130
command: |
4231
javac -version
4332
ant -version
4433
aws --version
34+
./buildproperties.sh -e DEV -k directapp
4535
ant package-direct package-static-direct
4636
- store_artifacts:
4737
path: ./direct.jar
@@ -148,24 +138,14 @@ jobs:
148138
wget http://downloads.sourceforge.net/project/jboss/JBoss/JBoss-4.2.3.GA/jboss-4.2.3.GA-jdk6.zip
149139
unzip jboss-4.2.3.GA-jdk6.zip
150140
cd project
151-
- run:
152-
name: checking out build repo
153-
command: |
154-
git clone --branch master https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
155-
#git clone --branch master git@github.com:appirio-tech/ops.git ../direct-config-update
156-
#git clone --branch master https://$GITUSER:$GITPASSWD@github.com/appirio-tech/ops ../direct-config-update
157141
- checkout
158-
- run:
159-
name: copying configuration file
160-
command: |
161-
cp ./../buildscript/direct/conf/prod/token.properties.enc .
162-
openssl enc -aes-256-cbc -d -in token.properties.enc -out token.properties -k $SECPASSWD
163142
- run:
164143
name: Installation of build dependencies.
165144
command: |
166145
javac -version
167146
ant -version
168147
aws --version
148+
./buildproperties.sh -e PROD -k directapp
169149
ant package-direct package-static-direct
170150
- store_artifacts:
171151
path: ./direct.jar

build-package.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ then
88
fi
99

1010
VER=`date "+%Y%m%d%H%M"`
11+
SCRIPTDIR="./scripts"
1112

1213
directapp_cdpacakge()
1314
{
@@ -16,7 +17,7 @@ directapp_cdpacakge()
1617
source $BUILD_VARIABLE_FILE_NAME
1718
AWS_CD_PACKAGE_NAME="${APPNAME}-${PACKAGETYPE}-${VER}.zip"
1819
PACAKAGE_LOCATION="dist-${PACKAGETYPE}"
19-
SCRIPTDIR="./../buildscript/direct/scripts"
20+
# SCRIPTDIR="./../buildscript/direct/scripts"
2021
rm -rf $PACAKAGE_LOCATION
2122
mkdir $PACAKAGE_LOCATION
2223
#cd $PACAKAGE_LOCATION

buildproperties.sh

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#!/bin/bash
2+
KEY_LOCATION=""
3+
BUILDENV_LIST=""
4+
usage()
5+
{
6+
cat << EOF
7+
usage: $0 options
8+
This script need to be executed with below option.
9+
OPTIONS:
10+
-e environment
11+
-b Security file location GIT|AWS
12+
-k key location
13+
EOF
14+
}
15+
#log Function - Used to provide information of execution information with date and time
16+
log()
17+
{
18+
echo "`date +'%D %T'` : $1"
19+
}
20+
track_error()
21+
{
22+
if [ $1 != "0" ]; then
23+
log "$2 exited with error code $1"
24+
log "completed execution IN ERROR at `date`"
25+
exit $1
26+
fi
27+
28+
}
29+
download_buildenvfile()
30+
{
31+
if [ -z "$BUILDENV_LIST" ];
32+
then
33+
if [ -z "$KEY_LOCATION" ];
34+
then
35+
track_error $? "Please provide the file list using -b or file location -k or both -b and -k "
36+
else
37+
aws s3 sync s3://tc-buildproperties-${ENV_CONFIG}/$KEY_LOCATION .
38+
track_error $? "Environment setting"
39+
fi
40+
41+
else
42+
Buffer_seclist=$(echo $BUILDENV_LIST | sed 's/,/ /g' )
43+
for listname in $Buffer_seclist;
44+
do
45+
if [ -z "$KEY_LOCATION" ];
46+
then
47+
aws s3 cp s3://tc-buildproperties-${ENV_CONFIG}/$listname .
48+
track_error $? "Environment setting"
49+
else
50+
aws s3 cp s3://tc-buildproperties-${ENV_CONFIG}/$KEY_LOCATION/$listname .
51+
track_error $? "Environment setting"
52+
fi
53+
done
54+
fi
55+
56+
}
57+
58+
configure_aws_cli() {
59+
aws --version
60+
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
61+
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
62+
aws configure set default.region $AWS_REGION
63+
aws configure set default.output json
64+
log "Configured AWS CLI."
65+
}
66+
67+
while getopts .b:e:k:. OPTION
68+
do
69+
case $OPTION in
70+
e)
71+
ENV=$OPTARG
72+
;;
73+
b)
74+
BUILDENV_LIST=$OPTARG
75+
;;
76+
k)
77+
KEY_LOCATION=$OPTARG
78+
;;
79+
?)
80+
log "additional param required"
81+
usage
82+
exit
83+
;;
84+
esac
85+
done
86+
87+
AWS_ACCESS_KEY_ID=$(eval "echo \$${ENV}_AWS_ACCESS_KEY_ID")
88+
AWS_SECRET_ACCESS_KEY=$(eval "echo \$${ENV}_AWS_SECRET_ACCESS_KEY")
89+
AWS_REGION=$(eval "echo \$${ENV}_AWS_REGION")
90+
if [ -z $AWS_REGION ];
91+
then
92+
AWS_REGION="us-east-1"
93+
fi
94+
if [ -z $AWS_ACCESS_KEY_ID ] || [ -z $AWS_SECRET_ACCESS_KEY ] ;
95+
then
96+
log "AWS Secret Parameters are not configured in circleci/environment"
97+
usage
98+
exit 1
99+
else
100+
configure_aws_cli
101+
fi
102+
ENV_CONFIG=`echo "$ENV" | tr '[:upper:]' '[:lower:]'`
103+
download_buildenvfile

deploy.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ COUNTER_LIMIT=20
1515
BUILD_VARIABLE_FILE_NAME="./buildvar.conf"
1616
source $BUILD_VARIABLE_FILE_NAME
1717

18-
SECRET_FILE_NAME="${APPNAME}-buildsecvar.conf"
19-
cp ./../buildscript/${APPNAME}/${SECRET_FILE_NAME}.enc .
20-
if [ -f "$SECRET_FILE_NAME" ];
21-
then
22-
rm -rf $SECRET_FILE_NAME
23-
fi
24-
openssl enc -aes-256-cbc -d -in $SECRET_FILE_NAME.enc -out $SECRET_FILE_NAME -k $SECPASSWD
25-
source $SECRET_FILE_NAME
18+
# SECRET_FILE_NAME="${APPNAME}-buildsecvar.conf"
19+
# cp ./../buildscript/${APPNAME}/${SECRET_FILE_NAME}.enc .
20+
# if [ -f "$SECRET_FILE_NAME" ];
21+
# then
22+
# rm -rf $SECRET_FILE_NAME
23+
# fi
24+
# openssl enc -aes-256-cbc -d -in $SECRET_FILE_NAME.enc -out $SECRET_FILE_NAME -k $SECPASSWD
25+
# source $SECRET_FILE_NAME
2626

2727
AWS_REGION=$(eval "echo \$${ENV}_AWS_REGION")
2828
AWS_ACCESS_KEY_ID=$(eval "echo \$${ENV}_AWS_ACCESS_KEY_ID")

0 commit comments

Comments
 (0)