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:
-
export ORACLE_HOME=/usr/lib/oracle/12.1/client64
-
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:
-
/usr/lib/oracle/12.1/client64/lib/
sudo cp /usr/bin/sqlplus64 /usr/bin/sqlplus
sqlplus username/password@//dbhost:1521/SID
Setup JDK
-
sudo apt-get install openjdk-8-jdk
Setup default java home
-
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
-
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
-
<localRepository/>
-
<interactiveMode/>
-
<usePluginRegistry/>
-
<offline/>
-
<pluginGroups/>
-
<servers>
-
<server>
-
<id>ssh-snapshot-repository</id>
-
<username>maven_repo</username>
-
</server>
-
<server>
-
<id>ssh-repository</id>
-
<username>maven_repo</username>
-
</server>
-
</servers>
-
<mirrors/>
-
<proxies/>
-
<profiles/>
-
<activeProfiles/>
-
</settings>
Generate openssl keys
-
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:
-
sudo vi /etc/environment
add the line
-
CIICENV_HOME=/home/robert/ic_ci_env
Create the directory structure:
-
mkdir ${CIICENV_HOME}
-
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