CI Server Build

Submitted by code_admin on Wed, 07/25/2018 - 10:33

My build process to build a Simple CI Server

My aim is to get a CI server which
- checks out code from git
- runs maven
- uses sqlplus to install files to external DB

Step - Basic Setup

Created a VM for Ubuntu 64bit. Gave it 8gb Ram
Created a dynamically allocated HD. 100Gb
Installed Ubuntu Server 16.04

Hostname: simpleciserver
User: robert
Encrypt Home: No

Software selection:
standard system utilities
OpenSSH server

Configured Virtual Machine NAT routing SSH Rule to route port 2222 to port 22
Added authorized_key file for user robert

Step - Install SQL*Plus and connect to DB server on host machine

(This section is documented https://help.ubuntu.com/community/Oracle%20Instant%20Client)
From
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

download linux 64bit client:
(basic, JDBC Supplement, and SQL-Plus)
oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
oracle-instantclient12.1-jdbc-12.1.0.2.0-1.x86_64.rpm
oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm

Use FileZilla to upload to ~/tmp

sudo apt-get install alien
sudo alien -i oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
sudo alien -i oracle-instantclient12.1-jdbc-12.1.0.2.0-1.x86_64.rpm
sudo alien -i oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm

export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib/${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
sudo apt-get install libaio1

sudo sudo vi /etc/profile.d/oracle.sh && sudo chmod o+r /etc/profile.d/oracle.sh

Add the line:

  1. export ORACLE_HOME=/usr/lib/oracle/12.1/client64
  2. export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}

sudo vi /etc/ld.so.conf.d/oracle.conf && sudo chmod o+r /etc/ld.so.conf.d/oracle.conf

Add the line:

  1. /usr/lib/oracle/12.1/client64/lib/

sudo cp /usr/bin/sqlplus64 /usr/bin/sqlplus

sqlplus username/password@//dbhost:1521/SID

Setup JDK

  1. sudo apt-get install openjdk-8-jdk

Setup default java home

  1. sudo vi /etc/environment

Add:
JAVA_HOME="/usr/lib/jvm/default-java"

Setup Maven

Install

sudo apt install maven

mvn -version

Create default settings file

The default settings file gives the repo username for deploying:

This file is "settings.xml"
on linux it is stored in ~/.m2/
on Windows it is storedin C:\Users\USER.m2

  1.       xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
  2.                           https://maven.apache.org/xsd/settings-1.0.0.xsd">
  3.       <localRepository/>
  4.       <interactiveMode/>
  5.       <usePluginRegistry/>
  6.       <offline/>
  7.       <pluginGroups/>
  8.       <servers>
  9.           <server>
  10.               <id>ssh-snapshot-repository</id>
  11.                <username>maven_repo</username>
  12.           </server>
  13.           <server>
  14.               <id>ssh-repository</id>
  15.                <username>maven_repo</username>
  16.           </server>
  17.       </servers>
  18.       <mirrors/>
  19.       <proxies/>
  20.       <profiles/>
  21.       <activeProfiles/>
  22. </settings>

Generate openssl keys

  1. ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa

Add public keys where required

  • Add public key to git repo

Setup directory for deployable artifacts

mkdir -p ~/deployable_artifacts

** NO LONGER NEEDED ** Getting Flyway working

goto http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-1120…
and download ojdbc6.jar
goto https://github.com/hilverd/vagrant-ubuntu-oracle-xe/blob/master/oracle-… and download pom.xml
upload both files to ~/tmp directory

run:
mvn install:install-file -Dfile=~/tmp/ojdbc6.jar -DpomFile=pom.xml

TODO Install ciutils

Set Home
sudo vi /etc/environment
add
CIUTILS_HOME=/home/robert/ciutils

Install Imperial Environment

Add environment var to point to location:

  1. sudo vi /etc/environment

add the line

  1. CIICENV_HOME=/home/robert/ic_ci_env

Create the directory structure:

  1. mkdir ${CIICENV_HOME}
  2. mkdir ${CIICENV_HOME}/dev

Place needed files into ~/ic_ci_env/dev directory (soadb.properties etc.)
If required repeat for test, dev2, etc.

TODO Change this to using a git repo for DEV as the source
Note: This is for DEV only. Production will have a different structure

Test installing sample schema

cd ~/deployable_artifacts
git clone git@gitlab.com:rmetcalf9/ICSchema_SAMPLE_SCHEMA.git
cd ~/deployable_artifacts/ICSchema_SAMPLE_SCHEMA
mvn install
mvn deploy -Dcmd.env=dev

Other steps

Before deploying you must ssh to the repo server and accept the host key

RJM Article Type
Work Notes