Summary Table
| Categories |
Total Count |
| PII |
0 |
| URL |
0 |
| DNS |
0 |
| EKL |
0 |
| IP |
0 |
| PORT |
0 |
| VsID |
0 |
| CF |
0 |
| AI |
0 |
| VPD |
0 |
| PL |
0 |
| Other |
0 |
File Content
#!/bin/bash
printf "\n\n\n\n**** RUNNING BUILD ********************\n\n"
APPDATE=`date "+%B %d, %Y"`
if [ -z $APP_NAME ] || [ -z $APP_VERSION ]; then
source app.env
fi
if [ -z $BUILD_NUMBER ]; then
BUILD_NUMBER="SNAPSHOT"
fi
if [ -z $JOB_NAME ]; then
JOB_NAME=$APP_NAME
fi
if [ -z $STAGING_DIR ]; then
printf "STAGING_DIR not specified, defaulting to dist/\n";
STAGING_DIR="dist"
else
STAGING_DIR=$(echo ${STAGING_DIR} | sed 's:/*$::')
printf "Using staging directory '$STAGING_DIR'\n";
fi
if [ -d $STAGING_DIR ] && [ $STAGING_DIR != "." ]; then
printf "Cleaning staging directory...\n"
rm -r $STAGING_DIR
else
printf "No staging directory to be cleaned at ${STAGING_DIR}\n"
fi
if [ -z $BUILD_DIR ]; then
printf "Artifact directory 'BUILD_DIR' not specified, defaulting to build\n";
BUILD_DIR="build"
else
BUILD_DIR=$(echo ${BUILD_DIR} | sed 's:/*$::')
printf "Using build directory '$BUILD_DIR'\n";
fi
if [ -d $BUILD_DIR ] && [ $BUILD_DIR != "." ]; then
printf "Cleaning build directory...\n"
rm -r $BUILD_DIR
else
printf "No build directory to be cleaned at ${BUILD_DIR}\n"
fi
if [ -z ${DTR_PREFIX// }${DTR_ORG// } ]; then
printf "Both DTR_PREFIX and DTR_ORG not set, pointing Docker images to dev\n"
DTR_PREFIX=dev
fi
if [ -f $JOB_NAME*.tar.gz ]; then
printf "Cleaning old build artifacts from workspace root\n"
rm $JOB_NAME*.tar.gz
fi
cp gradle.properties gradle.properties.bak
cp VarUtilityServices/build.gradle VarUtilityServices/build.gradle.bak
cp VarUtilityServices/src/main/webapp/WEB-INF/web.xml VarUtilityServices/src/main/webapp/WEB-INF/web.xml.bak
cp VarUtilityServices/src/main/resources/properties/swagger.properties VarUtilityServices/src/main/resources/properties/swagger.properties.bak
/usr/bin/perl -i -pe "s|%%APP_VERSION%%|$APP_VERSION|" gradle.properties || { echo "FATAL: Could not set App Version"; exit 1; }
/usr/bin/perl -i -pe "s|%%APP_CONTEXT_VERSION%%|$APP_CONTEXT_VERSION|" VarUtilityServices/build.gradle || { echo "FATAL: Could not set App Context Version"; exit 1; }
/usr/bin/perl -i -pe "s|%%APP_CONTEXT_VERSION%%|$APP_CONTEXT_VERSION|" VarUtilityServices/src/main/webapp/WEB-INF/web.xml || { echo "FATAL: Could not set App Context Version"; exit 1; }
# Build the app
./gradlew clean build -x test || {
echo "FATAL: Gradle build failed -- can't continue";
# restore the changed files
mv gradle.properties.bak gradle.properties
mv VarUtilityServices/build.gradle.bak VarUtilityServices/build.gradle
mv VarUtilityServices/src/main/webapp/WEB-INF/web.xml.bak VarUtilityServices/src/main/webapp/WEB-INF/web.xml
mv VarUtilityServices/src/main/resources/properties/swagger.properties.bak VarUtilityServices/src/main/resources/properties/swagger.properties
exit 1;
}
mv gradle.properties.bak gradle.properties
mv VarUtilityServices/build.gradle.bak VarUtilityServices/build.gradle
mv VarUtilityServices/src/main/webapp/WEB-INF/web.xml.bak VarUtilityServices/src/main/webapp/WEB-INF/web.xml
mv VarUtilityServices/src/main/resources/properties/swagger.properties.bak VarUtilityServices/src/main/resources/properties/swagger.properties
mkdir -p $BUILD_DIR
mkdir -p $STAGING_DIR
cp app.env $STAGING_DIR
cp app.yml $STAGING_DIR
cp docker-compose-fortify.yml $STAGING_DIR
cp docker-compose.yml $STAGING_DIR
cp docker-compose-beta.yml $STAGING_DIR
cp Dockerfile $STAGING_DIR
cp VarUtilityServices/build/libs/*.war $STAGING_DIR
#cp ROOT.xml $STAGING_DIR
cp entrypoint.sh $STAGING_DIR
cp -r tomcat $STAGING_DIR
# Set DTR for Docker - Perform against ALL Dockerfiles in your project
/usr/bin/perl -i -pe "s|%%DTR_PREFIX%%|$DTR_PREFIX|g" $STAGING_DIR/Dockerfile || { echo "FATAL: Could not set DTR Prefix"; exit 1; }
/usr/bin/perl -i -pe "s|%%DTR_ORG%%|$DTR_ORG|g" $STAGING_DIR/Dockerfile || { echo "FATAL: Could not set DTR Organization'"; exit 1; }
/usr/bin/perl -i -pe "s|%%APP_VERSION%%|$APP_VERSION|g" $STAGING_DIR/Dockerfile || { echo "FATAL: Could not set App Version"; exit 1; }
/usr/bin/perl -i -pe "s|%%APP_CONTEXT_VERSION%%|$APP_CONTEXT_VERSION|g" $STAGING_DIR/Dockerfile || { echo "FATAL: Could not set App Context Version"; exit 1; }
# Build Artifact Production
printf "\n\n**** Optional: Producing Build Artifacts ********************\n\n"
ARTIFACT="${BUILD_DIR}/${JOB_NAME}.BUILD-${BUILD_NUMBER}.tar.gz"
printf "Building application artifact ${ARTIFACT}...\n\n"
tar -C $STAGING_DIR -zcvf $ARTIFACT . || { echo "FATAL: Failed on 'Artifact tar''"; exit 1; }
cp $ARTIFACT .
printf "\n\n\n\n**** COMPLETED BUILD ********************\n\n"