Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 29ce4b5
Showing
22 changed files
with
477 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Freeware License, some rights reserved | ||
|
||
Copyright (c) 2017 Nikhil Pathania | ||
|
||
Permission is hereby granted, free of charge, to anyone obtaining a copy | ||
of this software and associated documentation files (the "Software"), | ||
to work with the Software within the limits of freeware distribution and fair use. | ||
This includes the rights to use, copy, and modify the Software for personal use. | ||
Users are also allowed and encouraged to submit corrections and modifications | ||
to the Software for the benefit of other users. | ||
|
||
It is not allowed to reuse, modify, or redistribute the Software for | ||
commercial use in any way, or for a user�s educational materials such as books | ||
or blog articles without prior permission from the copyright holder. | ||
|
||
The above copyright notice and this permission notice need to be included | ||
in all copies or substantial portions of the software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
node('master'){ | ||
stage('build'){ | ||
sh 'mvn clean install'; | ||
} | ||
stage('static code analysis'){ | ||
sh 'mvn verify sonar:sonar'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[Unit] | ||
Description=Jenkins Master Server | ||
|
||
After=docker.service | ||
Requires=docker.service | ||
|
||
[Service] | ||
TimeoutStartSec=0 | ||
ExecStartPre=-/usr/bin/docker kill jenkins%i | ||
ExecStartPre=-/usr/bin/docker rm jenkins%i | ||
|
||
ExecStart=/usr/bin/docker run --privileged --name jenkins%i -p 8080:8080 jenkinsci/jenkins:lts | ||
|
||
ExecStop=/usr/bin/docker stop jenkins%i | ||
|
||
[X-Fleet] | ||
Conflicts=jenkins@*.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* CI starts */ | ||
node('docker-ci-agent'){ | ||
|
||
stage('build'){ | ||
// some build step | ||
} | ||
|
||
stage('integration testing'){ | ||
// some integration steps | ||
} | ||
|
||
} | ||
/* CI ends */ | ||
|
||
/* Testing starts */ | ||
parallel stage('acceptance test chrome'){ | ||
|
||
node('docker-chrome'){ | ||
// steps to perform acceptance test on chrome | ||
} | ||
|
||
}, | ||
stage('acceptance test Opera'){ | ||
|
||
node('docker-opera'){ | ||
//steps to perform acceptance test on opera | ||
} | ||
|
||
} | ||
|
||
stage('acceptance test firefox'){ | ||
|
||
node('docker-firefox'){ | ||
//steps to perform acceptance test on firefox | ||
} | ||
|
||
} | ||
/* Testing ends */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
########################################################### | ||
# Dockerfile for Maven build container images | ||
# Based on Ubuntu | ||
########################################################### | ||
|
||
# Set the base image to Ubuntu | ||
FROM ubuntu | ||
|
||
# Author / Maintainer | ||
Nikhil Pathania | ||
|
||
########################################################### | ||
|
||
# Update the repository sources list | ||
RUN apt-get update | ||
|
||
# Install Maven | ||
RUN apt-get install maven | ||
|
||
# Install Java | ||
RUN apt-get install default-jre |
25 changes: 25 additions & 0 deletions
25
Pathania_Code/Chapter 2/Ch2_Pathania_Page10_Vagrantfile.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
Vagrant.configure(2) do |config| | ||
config.vm.box = "ubuntu/trusty64" | ||
|
||
config.vm.define :node1 do |node1_config| | ||
node1_config.vm.host_name = "node1" | ||
node1_config.vm.network "private_network", ip:"172.17.8.104" | ||
node1_config.vm.provider :virtualbox do |vb| | ||
vb.customize ["modifyvm", :id, "--memory", "1024"] | ||
vb.customize ["modifyvm", :id, "--cpus", "1"] | ||
end | ||
end | ||
|
||
config.vm.define :node2 do |node2_config| | ||
node2_config.vm.host_name = "node2" | ||
node2_config.vm.network "private_network", ip:"172.17.8.105" | ||
node2_config.vm.provider :virtualbox do |vb| | ||
vb.customize ["modifyvm", :id, "--memory", "1024"] | ||
vb.customize ["modifyvm", :id, "--cpus", "1"] | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Please read the openais.conf.5 manual page | ||
totem { | ||
version: 2 | ||
cluster_name: HA cluster for Jenkins | ||
transport: udpu | ||
|
||
# How long before declaring a token lost (ms) | ||
token: 3000 | ||
|
||
# How many token retransmits before forming a new configuration | ||
token_retransmits_before_loss_const: 10 | ||
|
||
# How long to wait for join messages in the membership protocol (ms) | ||
join: 60 | ||
|
||
# How long to wait for consensus to be achieved before starting a new round of membership configuration (ms) | ||
consensus: 3600 | ||
|
||
# Turn off the virtual synchrony filter | ||
vsftype: none | ||
|
||
# Number of messages that may be sent by one processor on receipt of the token | ||
max_messages: 20 | ||
|
||
# Limit generated nodeids to 31-bits (positive signed integers) | ||
clear_node_high_bit: yes | ||
|
||
# Disable encryption | ||
secauth: off | ||
|
||
# How many threads to use for encryption/decryption | ||
threads: 0 | ||
|
||
# Optionally assign a fixed node id (integer) | ||
# nodeid: 1234 | ||
|
||
# This specifies the mode of redundant ring, which may be none, active, or passive. | ||
rrp_mode: none | ||
|
||
interface { | ||
# The following values need to be set based on your environment | ||
ringnumber: 0 | ||
bindnetaddr: 172.17.8.104 | ||
mcastaddr: 226.94.1.1 | ||
mcastport: 5405 | ||
} | ||
} | ||
|
||
amf { | ||
mode: disabled | ||
} | ||
|
||
quorum { | ||
# Quorum for the Pacemaker Cluster Resource Manager | ||
provider: corosync_votequorum | ||
expected_votes: 1 | ||
} | ||
|
||
aisexec { | ||
user: root | ||
group: root | ||
} | ||
|
||
nodelist { | ||
node { | ||
ring0_addr: 172.17.8.104 | ||
name: primary | ||
nodeid: 1 | ||
} | ||
node { | ||
ring0_addr: 172.17.8.105 | ||
name: secondary | ||
nodeid: 2 | ||
} | ||
} | ||
|
||
logging { | ||
fileline: off | ||
to_stderr: yes | ||
to_logfile: yes | ||
logfile: /var/log/corosync/corosync.log | ||
to_syslog: yes | ||
syslog_facility: daemon | ||
debug: off | ||
timestamp: on | ||
logger_subsys { | ||
subsys: AMF | ||
debug: off | ||
tags: enter|leave|trace1|trace2|trace3|trace4|trace6 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
service { | ||
name: pacemaker | ||
ver: 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
resource data { | ||
protocol C; | ||
volume 0 { | ||
device /dev/drbd1; | ||
disk /dev/sdb1; | ||
meta-disk internal; | ||
} | ||
volume 1 { | ||
device /dev/drbd2; | ||
disk /dev/sdb2; | ||
meta-disk internal; | ||
} | ||
syncer { | ||
verify-alg sha1; | ||
} | ||
net { | ||
allow-two-primaries; | ||
} | ||
on node1 { | ||
address 172.17.8.104:7789; | ||
} | ||
on node2 { | ||
address 172.17.8.105:7789; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
Pathania_Code/Chapter 3/Ch3_Pathania_Page17_jenkins_a@.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[Unit] | ||
Description=Jenkins Master Server with GlusterFS client | ||
|
||
After=docker.service | ||
Requires=docker.service | ||
|
||
Before=jenkins_b@%i.service | ||
Wants=jenkins_b@%i.service | ||
|
||
[Service] | ||
TimeoutStartSec=0 | ||
ExecStartPre=-/usr/bin/docker kill jenkins%i | ||
ExecStartPre=-/usr/bin/docker rm jenkins%i | ||
ExecStartPre=/usr/bin/docker pull nikhilpathania/jenkins_glusterfs_client | ||
ExecStartPre=/usr/bin/sudo /usr/bin/ip addr add 172.17.8.200/24 dev eth1 | ||
|
||
ExecStart=/usr/bin/docker run --privileged --name jenkins%i -p 8080:8080 nikhilpathania/jenkins_glusterfs_client | ||
|
||
ExecStop=/usr/bin/docker stop jenkins%i | ||
ExecStopPost=/usr/bin/sudo /usr/bin/ip addr del 172.17.8.200/24 dev eth1 | ||
|
||
[X-Fleet] | ||
Conflicts=jenkins_a@*.service |
23 changes: 23 additions & 0 deletions
23
Pathania_Code/Chapter 3/Ch3_Pathania_Page18_glusterfs_a@.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[Unit] | ||
Description=Glusterfs Server | ||
|
||
After=docker.service | ||
Requires=docker.service | ||
|
||
Before=glusterfs_b@%i.service | ||
Wants=glusterfs_b@%i.service | ||
|
||
[Service] | ||
TimeoutStartSec=0 | ||
ExecStartPre=-/usr/bin/docker kill glusterfs%i | ||
ExecStartPre=-/usr/bin/docker rm glusterfs%i | ||
ExecStartPre=/bin/bash -c 'if [[ $(docker images --format "{{.Repository}}" gluster/gluster-centos:latest) ]]; then echo "image gluster/gluster-centos:latest already exists"; else /usr/bin/docker pull gluster/gluster-centos:latest; fi' | ||
|
||
ExecStart=/usr/bin/docker run --privileged --name glusterfs%i --net=host -p 22:22 gluster/gluster-centos:latest | ||
|
||
ExecStop=/usr/bin/docker stop glusterfs%i | ||
ExecStopPost=-/usr/bin/docker rmi gluster/gluster-centos:last | ||
ExecStopPost=/bin/bash -c '/usr/bin/docker tag gluster/gluster-centos:latest gluster/gluster-centos:last && /usr/bin/docker rmi gluster/gluster-centos:latest && /usr/bin/docker commit glusterfs%i gluster/gluster-centos:latest' | ||
|
||
[X-Fleet] | ||
Conflicts=glusterfs_a@*.service |
20 changes: 20 additions & 0 deletions
20
Pathania_Code/Chapter 3/Ch3_Pathania_Page18_jenkins_b@.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[Unit] | ||
Description=Mount /var/jenkins_home to /volume1 | ||
|
||
After=docker.service | ||
Requires=docker.service | ||
|
||
After=jenkins_a@%i.service | ||
Requires=jenkins_a@%i.service | ||
BindsTo=jenkins_a@1.service | ||
|
||
[Service] | ||
TimeoutStartSec=0 | ||
|
||
ExecStart=/usr/bin/docker exec -u root jenkins%i /bin/bash -c 'cp -R /var/jenkins_home /var/jenkins_home_backup && mount.glusterfs 172.17.8.101:/volume1 /var/jenkins_home && if [ "$(ls -A /var/jenkins_home)" ]; then echo "jenkins_home directory is in sync with GlusterFS Server"; else cp -R /var/jenkins_home_backup/. /var/jenkins_home; fi && chown -R jenkins:jenkins /var/jenkins_home' | ||
|
||
RestartSec=30 | ||
Restart=on-failure | ||
|
||
[X-Fleet] | ||
MachineOf=jenkins_a@%i.service |
11 changes: 11 additions & 0 deletions
11
Pathania_Code/Chapter 5/Ch5_Pathania_Page32_Pipeline Script.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
node('master') { | ||
|
||
stage('scm') { | ||
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-jenkins-ssh-key', url: 'git@github.com:pro-continuous-delivery/hello-world-example.git']]]) | ||
} | ||
stage('build') { | ||
withMaven(jdk: 'Default Java', maven: 'Default Maven') { | ||
sh 'mvn clean install' | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
node('master') { | ||
checkout scm | ||
stage('build') { | ||
withMaven(jdk: 'Default Java', maven: 'Default Maven') { | ||
sh 'mvn clean install' | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Pathania_Code/Chapter 6/Ch6_Pathania_Page13_Pipeline Script.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
node(docker) { | ||
|
||
stage('scm') { | ||
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-jenkins-ssh-key', url: 'git@github.com:pro-continuous-delivery/hello-world-example.git']]]) | ||
} | ||
stage('build') { | ||
withMaven(jdk: 'Default Java', maven: 'Default Maven') { | ||
sh 'mvn clean install' | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
node(docker) { | ||
checkout scm | ||
stage('build') { | ||
withMaven(jdk: 'Default Java', maven: 'Default Maven') { | ||
sh 'mvn clean install' | ||
} | ||
} | ||
} |
Oops, something went wrong.