-
Notifications
You must be signed in to change notification settings - Fork 13
CircleCI Integration
Note this guide uses the former
Kikaha v2.0.4and the circleci's versionv2.0.
Automate your pipeline from commit to deploy using CircleCi in Kikaha.
Sample .circleci/config.yml file in your project directory (example: /kikaha-api).
version: 2
jobs:
build:
# Set working diretory
working_directory: ~/kikaha-api
# Import docker image for java
docker:
- image: circleci/openjdk:8-jdk-browsers
# Declare steps needed
steps:
# Git checkout latest code.
- checkout
# Restores cache if any
- restore_cache:
key: kikaha-api-{{ checksum "pom.xml" }}
# Run mvn go-offline for optimasation
- run: mvn dependency:go-offline
# Save cache for any mvn dependency download
- save_cache:
paths:
- ~/.m2
key: kikaha-api-{{ checksum "pom.xml" }}
# Install rsync, we need it to copy files from dynamic boot environment to target server
- run: sudo apt install rsync
# Deploy info
- deploy:
# Git branch name to deploy
name: deploy master
command: |
# Multiple profile to support multiple instances of kikaha on a single server.
MVN_PROFILE="production_instance_1"
TARGET_DIR=/tmp
case $MVN_PROFILE in production_instance_1)
TARGET_DIR=/opt/dir/kikaha-api
break
;;
production_instance_2)
TARGET_DIR=/opt/dir/kikaha-api2
break
;;
production_instance_3)
TARGET_DIR=/opt/dir/kikaha-api3
;;
esac
rsync -avz -e 'ssh -p 222 -o StrictHostKeyChecking=no' --progress /home/circleci/kikaha-api/ <host-user>@<host-ip-address>:$TARGET_DIR
STATUS=$?
if [ $STATUS -eq 0 ]; then
ssh -p 222 -o StrictHostKeyChecking=no <host-user>@<host-ip-address> MP=$MVN_PROFILE TD=$TARGET_DIR 'bash -s' <<'ENDSSH'
# Change directory to target/working directory.
cd $TD
# Stop kikaha running instance, if any.
if [[ -f output/kikaha-api-0.0.1/bin/kikaha.sh ]]; then
sh output/kikaha-api-0.0.1/bin/kikaha.sh stop
else
echo "kikaha.sh stop failed. File does not exists"
fi
# Perform `mvn clean install -P <Maven Profile>`
# Maven lets you specify either goals or lifecycle phases on the command line (or both).
# You can call more than one target goal with maven. mvn clean install calls clean first, then install .
# You have to clean manually, because clean is not a standard target goal
# and not executed automatically on every install.
mvn clean install -P $MP
STATUS=$?
# Handle success.
if [ $STATUS -eq 0 ]; then
echo "Maven build is successful."
# Output directory.
cd output/
pwd
# Extract .zip file created by the CircleCI.
unzip kikaha-api-0.0.1.zip
STATUS=$?
if [ $STATUS -eq 0 ]; then
echo "Unzip is successful."
sh kikaha-api-0.0.1/bin/kikaha.sh start
STATUS=$?
if [ $STATUS -eq 0 ]; then
echo "Service has started!"
if [[ -f kikaha-api-0.0.1/server.log ]]; then
tail -f kikaha-api-0.0.1/server.log
fi
else
echo "Failed to start service.."
fi
else
echo "Unzip has failed."
fi
else
echo "Maven build has failed."
fi
ENDSSH
else
echo "Rsync has failed. Please check and try again."
fi
workflows:
version: 2
build:
jobs:
- build
WELCOME
About
Kikaha philosophy
GETTING STARTED
Getting started in 1 minute
Creating a Kikaha maven project
Architecture overview
TUTORIALS
Logging configuration
Configuring the server
Creating your first HTTP route
Kikaha's command line interface
Configuring your favorite IDE
Wro4j Integration
CircleCI Integration
CORE FEATURES
HTTP and HTTPS
Routing static assets
Dependency injection
Authentication and authorization
Smart routes
ESSENTIAL MODULES
μRouting API
WebSocket Routing
Database Connection Pool
JSON with Jackson
Protobuf
Mustache Templates
Rocker Templates
BCrypt
CLOUD MODULES
Overview of Cloud Modules
Consul.io
Codahale's Metrics
Auth0 Single Sign-On
μWorkers - Actor-like API
Hazelcast
AWS-RELATED MODULES
Overview of AWS-Related Modules
Deploying Applications on AWS
AWS IAM Credentials
AWS EC2
AWS SQS queues
AWS CloudWatch metrics
AWS Application Load Balancer
AWS Lambda functions
AWS X-Ray
ADVANCED TOPICS
Creating custom modules
Routing with Undertow's API
Creating custom cloud modules