We now try to automate the build of all needed images as soon as Oracle GitHub Sources changed or we need to build our Vagrant VirtualBox again from scratch.
This is a follow up to earlier Virtual Development Server: Provide Docker images in docker registry for Oracle XE Database and others blog.
After we have already installed Jenkins we now install first some needed plugins.
-
We select explicit plugins at Jenkins Configuration
-
Pipeline and Pipeline Stage View
-
Git
-
SSH Slaves
-
and wait for the install process
-
Later we add Blue Ocean Beta via "Manage Jenkins" > "Manage Plugins"
-
After all is installed we restart Jenkins
After that we create our Jenkins pipeline via "New Item".
-
We give it a name and select pipeline.
-
As we do not own the git repository and cannot create a hook there, we create a simple scm poll schedule.
-
Then we add our pipeline script.
Here is the script for the moment, later after we have it successfully tested and implemented all builds of images we need, we will put it in it’s own git repository and call it from there. The script is written in Pipeline Model Definition, a config-like syntax for defining Pipelines.
pipeline {
agent label:'localhost_vagrant'
stages {
// Get the actual docker images sourcse from oracle git account
stage('Get Sources') {
steps {
git url: 'https://github.com/oracle/docker-images.git'
}
}
stage('Build Oracle Docker Images') {
steps {
parallel (
"Database XE 11.2.0.2" : {
dir('OracleDatabase/dockerfiles') {
// provide the downloaded source (via your oracle account) from the host
sh 'if [ ! -f 11.2.0.2/oracle-xe-11.2.0-1.0.x86_64.rpm.zip ]; then cp /software/Oracle/Database/oracle-xe-11.2.0-1.0.x86_64.rpm.zip 11.2.0.2/oracle-xe-11.2.0-1.0.x86_64.rpm.zip; fi'
// build the image
sh 'sudo ./buildDockerImage.sh -v 11.2.0.2 -x'
// prepare the image for push to the local registry
sh 'docker tag oracle/database:11.2.0.2-xe localhost:5000/oracle/database:11.2.0.2-xe'
// push to the local registry
sh 'docker push localhost:5000/oracle/database:11.2.0.2-xe'
}
},
"WebLogic 12.2.1.2" : {
// server-jre is required for Weblogic
dir('OracleJava/java-8') {
// provide the downloaded source (via your oracle account) from the host
sh 'if [ ! -f server-jre-8u111-linux-x64.tar.gz ]; then cp /software/Oracle/Java/server-jre-8u111-linux-x64.tar.gz server-jre-8u111-linux-x64.tar.gz; fi'
// build the image
sh 'sudo ./build.sh'
// prepare the image for push to the local registry
sh 'docker tag oracle/serverjre:8 localhost:5000/oracle/serverjre:8'
// push to the local registry
sh 'docker push localhost:5000/oracle/serverjre:8'
}
dir('OracleWebLogic/dockerfiles') {
// provide the downloaded source (via your oracle account) from the host
sh 'if [ ! -f 12.2.1.2/fmw_12.2.1.2.0_wls_Disk1_1of1.zip ]; then cp /software/Oracle/WebLogic/fmw_12.2.1.2.0_wls_Disk1_1of1.zip 12.2.1.2/fmw_12.2.1.2.0_wls_Disk1_1of1.zip; fi'
// build the image
sh 'sudo ./buildDockerImage.sh -v 12.2.1.2 -g'
// prepare the image for push to the local registry
sh 'docker tag oracle/weblogic:12.2.1.2-generic localhost:5000/oracle/weblogic:12.2.1.2-generic'
// push to the local registry
sh 'docker push localhost:5000/oracle/weblogic:12.2.1.2-generic'
}
}
)
}
}
stage('Cleanup') {
steps {
// clean virtualbox
sh 'docker rmi --force localhost:5000/oracle/database:11.2.0.2-xe'
sh 'docker rmi --force oracle/database:11.2.0.2-xe'
sh 'docker rmi --force localhost:5000/oracle/weblogic:12.2.1.2-generic'
sh 'docker rmi --force oracle/weblogic:12.2.1.2-generic'
sh 'docker rmi --force localhost:5000/oracle/serverjre:8'
sh 'docker rmi --force oracle/serverjre:8'
}
}
}
}
We can wait now the 15 min poll time or start the job manually.
-
In the standard view you can see several information about the pipeline stages. Click on "Open Blue Ocean" now.
-
You see now an overview of last runs. Click now on the latest on the top.
-
Here you see at run-time a nice animation what’s actually going on and the according logs. For our pipeline you see here parallel steps in the run.
After an "vagrant halt / vagrant up" you can control in your browser, that the created images are persistent in the local docker registry:
Here you find the source code for this blog.
Here you find more about the topic "Virtual Development Server".
That’s it!