I’m trying to migrate my Springboot deployment from 1.0 to 2.0 but for some reason the Deploy Job is not finding the built war file.
I have tested the Build and can see the Artefact but when the Deploy Job starts, it is no longer there.
Post Build
ls
Container 0
- home/
- circleci/
- passedon/
- target/
- classes/
- maven-archiver/
- maven-status/
- passedon/
- [passedon.war]
- [passedon.war.original]
- target/
- passedon/
- circleci/
The Build Job
version: 2
jobs:
# The build job
build:
working_directory: ~/passedon
machine: true
steps:
# Checkout the code from the branch into the working_directory
- checkout
# Log the current branch
- run:
name: Retrieve GIT Information
command: |
echo ${CIRCLE_BRANCH}
echo ""
# GET GIT LATEST COMMIT COMMENT TO SET AS APP VERSION FOR BEANSTALK
COMMIT_MESSAGE=$(git log -1 --pretty=%f)
export COMMIT_MESSAGE
echo $COMMIT_MESSAGE
# Copy Environment specific application.properties and constant file
- run:
name: App Properties and Constant file
command: |
if [ "${CIRCLE_BRANCH}" == "integration" ]; then
echo ""
echo "Move Integration Application.Prop File"
mv src/main/resources/application.properties.integration src/main/resources/application.properties
if [ $? != 0 ]; then
echo "FAILED: Move app.prop: $? - Unsuccessful"
else
echo "SUCCESS: Move app.prop DONE 1 of 2"
fi
echo ""
echo "Move Constant.java File"
mv Constant-integration.java src/main/java/com/passedon/Constant.java
if [ $? != 0 ]; then
echo "FAILED: Move constant: $? - Unsuccessful"
else
echo "SUCCESS: Constant mv done 2 of 2"
fi
echo ""
echo "MESSAGE: Ensure 2 of 2 Successes"
echo ""
elif [ "${CIRCLE_BRANCH}" == "master" ]; then
echo ""
echo "Move PRODUCTION Application.Prop File"
mv src/main/resources/application.properties.production src/main/resources/application.properties
if [ $? != 0 ]; then
echo "FAILED: Move app.prop: $? - Unsuccessful"
else
echo "SUCCESS: Move app.prop DONE 1 of 2"
fi
echo ""
echo "Move Constant.java File"
mv Constant-production.java src/main/java/com/passedon/Constant.java
if [ $? != 0 ]; then
echo "FAILED: Move constant: $? - Unsuccessful"
else
echo "SUCCESS: Constant mv done 2 of 2"
fi
echo ""
echo "MESSAGE: Ensure 2 of 2 Successes"
echo ""
fi
echo "Move .ebextensions into the correct folder"
mv .ebextensions/ src/main/webapp/
if [ $? != 0 ]; then
echo "FAILED: Move ebextension: $? - Unsuccessful"
else
echo "SUCCESS: ebextension mv DONE"
fi
echo ""
- restore_cache: # restore the saved cache after the first run or if `pom.xml` has changed
key: circleci-demo-java-spring-{{ checksum "pom.xml" }}
- run: mvn dependency:go-offline # gets the project dependencies
- save_cache: # saves the project dependencies
paths:
- ~/.m2
key: circleci-demo-java-spring-{{ checksum "pom.xml" }}
- run:
name: Build the JAR file
command: |
mvn clean package # run the actual tests
ls -1 ~/passedon/target
- store_artifacts: # store the uberjar as an artifact
path: target/passedon.war
# The deploy job
deploy:
working_directory: ~/passedon
machine: true
steps:
# Log the current branch
- run:
name: Show current branch
command: |
echo ${CIRCLE_BRANCH}
ls -l ~/passedon
# Install AWS cli
- run:
name: Install aws cli
command: |
sudo apt-get -y -qq update
sudo apt-get install python-pip python-dev build-essential
sudo pip install awsebcli --upgrade
# Deploy to the correct Elastic BEanstalk Environemnt corresponding to the current branch
- run:
name: Deploy to EBS
command: |
if [ "${CIRCLE_BRANCH}" == "integration" ]; then
echo "START EBS Integration Deployment"
eb init --region ap-southeast-2 --platform "64bit Amazon Linux 2017.03 v2.5.1 running Java 8" PassedOn
eb use passedon-int-jsb1
eb deploy passedon-int-jsb1 --label "$COMMIT_MESSAGE"
echo "COMPLETE EBS Integration Deployment done "
elif [ "${CIRCLE_BRANCH}" == "master" ]; then
echo "START EBS PRODUCTION Deployment"
# select correct environment and uses the default aws keys setup inside circle ci
eb use passedon-prod-jsb
# clean the app versions older than 2 days to avoid the 30 versions limit
eb labs cleanup-versions --older-than 2 --debug --verbose --force
# deploy the war file to beanstalk and set the app version using the latest commit message
eb deploy passedon-prod-jsb --label "$COMMIT_MESSAGE"
echo "COMPLETE EBS PRODUCTION Deployment done "
fi
workflows:
version: 2
# The build and deploy workflow
build_and_deploy:
jobs:
- build
# The deploy job will only run on the filtered branches and
# require the build job to be successful before it starts
- deploy:
requires:
- build
filters:
branches:
only:
- integration
- master