From 09f08bab33ffe32115ae3b1bdb5f5bc5f42df005 Mon Sep 17 00:00:00 2001 From: gesparza3 Date: Tue, 7 May 2019 10:54:04 -0700 Subject: [PATCH 01/39] Added packer scripts for provisioning Jenkins on CentOS --- .gitignore | 3 + vm-images/jenkins/jenkins_build.json | 51 ++++++++++++++++ vm-images/jenkins/src/ks.cfg | 87 ++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 vm-images/jenkins/jenkins_build.json create mode 100644 vm-images/jenkins/src/ks.cfg diff --git a/.gitignore b/.gitignore index 9c9642b1d..592a133a2 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ target/* .idea *.iml /target +packer_cache/ +*.vmdk +*.ovf diff --git a/vm-images/jenkins/jenkins_build.json b/vm-images/jenkins/jenkins_build.json new file mode 100644 index 000000000..5b1b1a86a --- /dev/null +++ b/vm-images/jenkins/jenkins_build.json @@ -0,0 +1,51 @@ +{ + "variables": { + "file": "http://mirrors.ocf.berkeley.edu/centos/7.6.1810/isos/x86_64/CentOS-7-x86_64-Minimal-1810.iso", + "checksum": "bd43d41e01c2a46b3cb23eb9139dce4b", + "type": "md5", + "non_gui": "false" + }, + "builders": [ + { + "type": "virtualbox-iso", + "iso_url": "{{ user `file` }}", + "iso_checksum": "{{ user `checksum` }}", + "iso_checksum_type": "md5", + "headless": "{{ user `non_gui` }}", + "output_directory": "builds", + "vm_name": "CentOS7", + "guest_os_type": "RedHat_64", + "disk_size": "10240", + "vboxmanage": [ + ["modifyvm", "{{.Name}}", "--memory", "2048"], + ["modifyvm", "{{.Name}}", "--cpus", "2"], + ["modifyvm", "{{.Name}}", "--audio", "none"], + ["modifyvm", "{{.Name}}", "--usb", "off"] + ], + "http_directory": "src", + "boot_wait": "5s", + "boot_command": [ + " text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg" + ], + "ssh_username": "admin", + "ssh_password": "admin", + "ssh_port": 22, + "ssh_wait_timeout": "10000s", + "guest_additions_path": "disable", + "shutdown_command": "echo 'admin' | sudo -S /sbin/halt -h -p" + } + ], + "provisioners": [{ + "type": "shell", + "inline": [ + "sleep 30", + "sudo yum upgrade", + "sudo yum install git -y", + "sudo yum install wget -y", + "sudo yum install java-1.8.0-openjdk-devel -y", + "sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo", + "sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key", + "sudo yum install jenkins -y" + ] + }] +} diff --git a/vm-images/jenkins/src/ks.cfg b/vm-images/jenkins/src/ks.cfg new file mode 100644 index 000000000..e659d3c6c --- /dev/null +++ b/vm-images/jenkins/src/ks.cfg @@ -0,0 +1,87 @@ +install +cdrom + +lang en_US.UTF-8 +keyboard us +timezone UTC + +network --bootproto=dhcp +firewall --disabled + +rootpw --plaintext packer +user --name=admin --password=admin +auth --enableshadow --passalgo=sha512 --kickstart +selinux --permissive + +text +skipx + +clearpart --all --initlabel +zerombr +autopart +bootloader --location=mbr + +firstboot --disable +reboot + +%packages --instLangs=en_US.utf8 --nobase --ignoremissing --excludedocs +@^minimal +@core + +-aic94xx-firmware +-atmel-firmware +-b43-openfwwf +-bfa-firmware +-ipw2100-firmware +-ipw2200-firmware +-ivtv-firmware +-iwl100-firmware +-iwl105-firmware +-iwl135-firmware +-iwl1000-firmware +-iwl2000-firmware +-iwl2030-firmware +-iwl3160-firmware +-iwl3945-firmware +-iwl4965-firmware +-iwl5000-firmware +-iwl5150-firmware +-iwl6000-firmware +-iwl6000g2a-firmware +-iwl6000g2b-firmware +-iwl6050-firmware +-iwl7260-firmware +-libertas-usb8388-firmware +-ql2100-firmware +-ql2200-firmware +-ql23xx-firmware +-ql2400-firmware +-ql2500-firmware +-rt61pci-firmware +-rt73usb-firmware +-xorg-x11-drv-ati-firmware +-zd1211-firmware +%end + +%post --log=/root/ks.log +SEE NEXT PICTURE!!!! The security settings of my provider does not allow this content! +%end + +%post +echo "admin ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/admin +echo "Defaults:admin !requiretty" >> /etc/sudoers.d/admin +chmod 0440 /etc/sudoers.d/admin +mkdir -pm 700 /home/admin/.ssh +cat </home/admin/.ssh/authorized_keys +ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8Y\ +Vr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdO\ +KLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7Pt\ +ixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmC\ +P3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcW\ +yLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== admin insecure public key +EOK +chmod 0600 /home/admin/.ssh/authorized_keys +chown -R admin.admin /home/admin/.ssh +yum -y update +yum -y remove linux-firmware +%end From 354dec8214192d14297098b640549d347e608d56 Mon Sep 17 00:00:00 2001 From: gesparza3 Date: Tue, 7 May 2019 12:36:44 -0700 Subject: [PATCH 02/39] Updated vm name --- vm-images/jenkins/jenkins_build.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vm-images/jenkins/jenkins_build.json b/vm-images/jenkins/jenkins_build.json index 5b1b1a86a..620a6943b 100644 --- a/vm-images/jenkins/jenkins_build.json +++ b/vm-images/jenkins/jenkins_build.json @@ -13,13 +13,14 @@ "iso_checksum_type": "md5", "headless": "{{ user `non_gui` }}", "output_directory": "builds", - "vm_name": "CentOS7", + "vm_name": "jenkins_centos", "guest_os_type": "RedHat_64", "disk_size": "10240", "vboxmanage": [ ["modifyvm", "{{.Name}}", "--memory", "2048"], ["modifyvm", "{{.Name}}", "--cpus", "2"], ["modifyvm", "{{.Name}}", "--audio", "none"], + ["modifyvm", "{{.Name}}", "--nic1", "bridged"], ["modifyvm", "{{.Name}}", "--usb", "off"] ], "http_directory": "src", From 7fe2fe9047a941576af341e5dfafc670b1567017 Mon Sep 17 00:00:00 2001 From: Jordan A Date: Tue, 7 May 2019 12:41:50 -0700 Subject: [PATCH 03/39] Working Tomcat CentOS image built with packer --- .gitignore | 3 +- vm-images/tomcat/config/tomcat-users.xml | 51 ++++++++++++++ vm-images/tomcat/config/tomcat.conf | 51 ++++++++++++++ vm-images/tomcat/src/ks.cfg | 87 ++++++++++++++++++++++++ vm-images/tomcat/tomcat.sh | 6 ++ vm-images/tomcat/tomcat_build.json | 56 +++++++++++++++ 6 files changed, 252 insertions(+), 2 deletions(-) create mode 100644 vm-images/tomcat/config/tomcat-users.xml create mode 100644 vm-images/tomcat/config/tomcat.conf create mode 100644 vm-images/tomcat/src/ks.cfg create mode 100644 vm-images/tomcat/tomcat.sh create mode 100644 vm-images/tomcat/tomcat_build.json diff --git a/.gitignore b/.gitignore index 592a133a2..a4381843c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,4 @@ target/* *.iml /target packer_cache/ -*.vmdk -*.ovf +builds/ diff --git a/vm-images/tomcat/config/tomcat-users.xml b/vm-images/tomcat/config/tomcat-users.xml new file mode 100644 index 000000000..61d2b4889 --- /dev/null +++ b/vm-images/tomcat/config/tomcat-users.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + diff --git a/vm-images/tomcat/config/tomcat.conf b/vm-images/tomcat/config/tomcat.conf new file mode 100644 index 000000000..bdfeb770a --- /dev/null +++ b/vm-images/tomcat/config/tomcat.conf @@ -0,0 +1,51 @@ +# System-wide configuration file for tomcat services +# This will be loaded by systemd as an environment file, +# so please keep the syntax. For shell expansion support +# place your custom files as /etc/tomcat/conf.d/*.conf +# +# There are 2 "classes" of startup behavior in this package. +# The old one, the default service named tomcat.service. +# The new named instances are called tomcat@instance.service. +# +# Use this file to change default values for all services. +# Change the service specific ones to affect only one service. +# For tomcat.service it's /etc/sysconfig/tomcat, for +# tomcat@instance it's /etc/sysconfig/tomcat@instance. + +# This variable is used to figure out if config is loaded or not. +TOMCAT_CFG_LOADED="1" + +# In new-style instances, if CATALINA_BASE isn't specified, it will +# be constructed by joining TOMCATS_BASE and NAME. +TOMCATS_BASE="/var/lib/tomcats/" + +# Where your java installation lives +JAVA_HOME="/usr/lib/jvm/jre" + +# Where your tomcat installation lives +CATALINA_HOME="/usr/share/tomcat" + +# System-wide tmp +CATALINA_TMPDIR="/var/cache/tomcat/temp" + +# You can pass some parameters to java here if you wish to +#JAVA_OPTS="-Xminf0.1 -Xmaxf0.3" + +# Use JAVA_OPTS to set java.library.path for libtcnative.so +#JAVA_OPTS="-Djava.library.path=/usr/lib" + +# You can change your tomcat locale here +#LANG="en_US" + +# Run tomcat under the Java Security Manager +SECURITY_MANAGER="false" + +# Time to wait in seconds, before killing process +# TODO(stingray): does nothing, fix. +# SHUTDOWN_WAIT="30" + +# If you wish to further customize your tomcat environment, +# put your own definitions here +# (i.e. LD_LIBRARY_PATH for some jdbc drivers) +JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true -Xmx512m -XX:MaxPermSize=256m -XX:+UseConcMarkSweepGC" + diff --git a/vm-images/tomcat/src/ks.cfg b/vm-images/tomcat/src/ks.cfg new file mode 100644 index 000000000..e659d3c6c --- /dev/null +++ b/vm-images/tomcat/src/ks.cfg @@ -0,0 +1,87 @@ +install +cdrom + +lang en_US.UTF-8 +keyboard us +timezone UTC + +network --bootproto=dhcp +firewall --disabled + +rootpw --plaintext packer +user --name=admin --password=admin +auth --enableshadow --passalgo=sha512 --kickstart +selinux --permissive + +text +skipx + +clearpart --all --initlabel +zerombr +autopart +bootloader --location=mbr + +firstboot --disable +reboot + +%packages --instLangs=en_US.utf8 --nobase --ignoremissing --excludedocs +@^minimal +@core + +-aic94xx-firmware +-atmel-firmware +-b43-openfwwf +-bfa-firmware +-ipw2100-firmware +-ipw2200-firmware +-ivtv-firmware +-iwl100-firmware +-iwl105-firmware +-iwl135-firmware +-iwl1000-firmware +-iwl2000-firmware +-iwl2030-firmware +-iwl3160-firmware +-iwl3945-firmware +-iwl4965-firmware +-iwl5000-firmware +-iwl5150-firmware +-iwl6000-firmware +-iwl6000g2a-firmware +-iwl6000g2b-firmware +-iwl6050-firmware +-iwl7260-firmware +-libertas-usb8388-firmware +-ql2100-firmware +-ql2200-firmware +-ql23xx-firmware +-ql2400-firmware +-ql2500-firmware +-rt61pci-firmware +-rt73usb-firmware +-xorg-x11-drv-ati-firmware +-zd1211-firmware +%end + +%post --log=/root/ks.log +SEE NEXT PICTURE!!!! The security settings of my provider does not allow this content! +%end + +%post +echo "admin ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/admin +echo "Defaults:admin !requiretty" >> /etc/sudoers.d/admin +chmod 0440 /etc/sudoers.d/admin +mkdir -pm 700 /home/admin/.ssh +cat </home/admin/.ssh/authorized_keys +ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8Y\ +Vr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdO\ +KLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7Pt\ +ixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmC\ +P3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcW\ +yLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== admin insecure public key +EOK +chmod 0600 /home/admin/.ssh/authorized_keys +chown -R admin.admin /home/admin/.ssh +yum -y update +yum -y remove linux-firmware +%end diff --git a/vm-images/tomcat/tomcat.sh b/vm-images/tomcat/tomcat.sh new file mode 100644 index 000000000..82910deb9 --- /dev/null +++ b/vm-images/tomcat/tomcat.sh @@ -0,0 +1,6 @@ +sudo yum install tomcat -y +sudo yum install tomcat-webapps tomcat-admin-webapps -y +sudo mv tomcat-users.xml /usr/share/tomcat/conf/tomcat-users.xml +sudo mv tomcat.conf /usr/share/tomcat/conf/tomcat.conf +sudo systemctl enable tomcat + diff --git a/vm-images/tomcat/tomcat_build.json b/vm-images/tomcat/tomcat_build.json new file mode 100644 index 000000000..018a19a5b --- /dev/null +++ b/vm-images/tomcat/tomcat_build.json @@ -0,0 +1,56 @@ +{ + "variables": { + "file": "http://mirrors.ocf.berkeley.edu/centos/7.6.1810/isos/x86_64/CentOS-7-x86_64-Minimal-1810.iso", + "checksum": "bd43d41e01c2a46b3cb23eb9139dce4b", + "type": "md5", + "non_gui": "false" + }, + "builders": [ + { + "type": "virtualbox-iso", + "iso_url": "{{ user `file` }}", + "iso_checksum": "{{ user `checksum` }}", + "iso_checksum_type": "md5", + "headless": "{{ user `non_gui` }}", + "output_directory": "builds", + "vm_name": "Tomcat-CentOS7", + "guest_os_type": "RedHat_64", + "disk_size": "10240", + "vboxmanage": [ + ["modifyvm", "{{.Name}}", "--memory", "2048"], + ["modifyvm", "{{.Name}}", "--cpus", "2"], + ["modifyvm", "{{.Name}}", "--audio", "none"], + ["modifyvm", "{{.Name}}", "--usb", "off"] + ], + "http_directory": "src", + "boot_wait": "5s", + "boot_command": [ + " text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg" + ], + "ssh_username": "admin", + "ssh_password": "admin", + "ssh_port": 22, + "ssh_wait_timeout": "10000s", + "guest_additions_path": "disable", + "shutdown_command": "echo 'admin' | sudo -S /sbin/halt -h -p" + } + ], + "provisioners": [ + { + "type": "file", + "source": "config/tomcat-users.xml", + "destination": "~/tomcat-users.xml" + }, + { + "type": "file", + "source": "config/tomcat.conf", + "destination": "~/tomcat.conf" + }, + { + "type": "shell", + "scripts": [ + "tomcat.sh" + ] + } + ] +} From de58eb7cef99ea68d864105ee224e40097f08d09 Mon Sep 17 00:00:00 2001 From: gesparza3 Date: Tue, 7 May 2019 12:53:04 -0700 Subject: [PATCH 04/39] Removed bridged network --- vm-images/jenkins/jenkins_build.json | 1 - 1 file changed, 1 deletion(-) diff --git a/vm-images/jenkins/jenkins_build.json b/vm-images/jenkins/jenkins_build.json index 620a6943b..980979727 100644 --- a/vm-images/jenkins/jenkins_build.json +++ b/vm-images/jenkins/jenkins_build.json @@ -20,7 +20,6 @@ ["modifyvm", "{{.Name}}", "--memory", "2048"], ["modifyvm", "{{.Name}}", "--cpus", "2"], ["modifyvm", "{{.Name}}", "--audio", "none"], - ["modifyvm", "{{.Name}}", "--nic1", "bridged"], ["modifyvm", "{{.Name}}", "--usb", "off"] ], "http_directory": "src", From eb4c40ebb7fc381e1917c365cad6a61b575e5a3f Mon Sep 17 00:00:00 2001 From: gesparza3 Date: Wed, 8 May 2019 12:23:13 -0700 Subject: [PATCH 05/39] Updated Jenkinsfile to lay out steps --- Jenkinsfile | 212 +++------------------------------------------------- 1 file changed, 12 insertions(+), 200 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 85b61203e..0960fbbbf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,226 +1,38 @@ #!/bin/env groovy - -@Library('ldop-shared-library@fd16602cad0f97ca1b04090f93a0540ddc871b45') _ - pipeline { agent none - environment { - IMAGE = "liatrio/petclinic-tomcat" - } - stages { - stage('Build') { + stage('Test') { agent { - docker { - image 'maven:3.5.0' - args '-e INITIAL_ADMIN_USER -e INITIAL_ADMIN_PASSWORD --network=${LDOP_NETWORK_NAME}' + node { + label 'tester' } } steps { - configFileProvider([configFile(fileId: 'nexus', variable: 'MAVEN_SETTINGS')]) { - sh 'mvn -s $MAVEN_SETTINGS clean deploy -DskipTests=true -B' - } + sh '' } } - stage('Sonar') { + stage('Deploy to Artifactory') { agent { - docker { - image 'sebp/sonar-runner' - args '-e SONAR_ACCOUNT_LOGIN -e SONAR_ACCOUNT_PASSWORD -e SONAR_DB_URL -e SONAR_DB_LOGIN -e SONAR_DB_PASSWORD --network=${LDOP_NETWORK_NAME}' + node { + label 'tester' } } steps { - sh '/opt/sonar-runner-2.4/bin/sonar-runner -e -D sonar.login=${SONAR_ACCOUNT_LOGIN} -D sonar.password=${SONAR_ACCOUNT_PASSWORD} -D sonar.jdbc.url=${SONAR_DB_URL} -D sonar.jdbc.username=${SONAR_DB_LOGIN} -D sonar.jdbc.password=${SONAR_DB_PASSWORD}' + sh '' } } - stage('Get Artifact') { + stage('Deploy to QA') { agent { - docker { - image 'maven:3.5.0' - args '-e INITIAL_ADMIN_USER -e INITIAL_ADMIN_PASSWORD --network=${LDOP_NETWORK_NAME}' + node { + label 'tester' } } steps { - sh 'mvn clean' - script { - pom = readMavenPom file: 'pom.xml' - getArtifact(pom.groupId, pom.artifactId, pom.version, 'petclinic') - } - } - } - - stage('Build container') { - agent any - steps { - script { - if ( env.BRANCH_NAME == 'master' ) { - pom = readMavenPom file: 'pom.xml' - TAG = pom.version - } else { - TAG = env.BRANCH_NAME - } - sh "docker build -t ${env.IMAGE}:${TAG} ." - } - } - } - - stage('Run local container') { - agent any - steps { - sh 'docker rm -f petclinic-tomcat-temp || true' - sh "docker run -d --network=${LDOP_NETWORK_NAME} --name petclinic-tomcat-temp ${env.IMAGE}:${TAG}" - } - } - - stage('Smoke-Test & OWASP Security Scan') { - agent { - docker { - image 'maven:3.5.0' - args '--network=${LDOP_NETWORK_NAME}' - } - } - steps { - sh "cd regression-suite && mvn clean -B test -DPETCLINIC_URL=http://petclinic-tomcat-temp:8080/petclinic/" - } - } - stage('Stop local container') { - agent any - steps { - sh 'docker rm -f petclinic-tomcat-temp || true' - } - } - - stage('Push to dockerhub') { - agent any - steps { - withCredentials([usernamePassword(credentialsId: 'dockerhub', passwordVariable: 'dockerPassword', usernameVariable: 'dockerUsername')]){ - script { - sh "docker login -u ${env.dockerUsername} -p ${env.dockerPassword}" - sh "docker push ${env.IMAGE}:${TAG}" - } - } - } - } - - stage('Deploy to dev') { - when { - branch 'master' - } - agent any - steps { - script { - deployToEnvironment("ec2-user", "dev.petclinic.liatr.io", "petclinic-deploy-key", env.IMAGE, TAG, "spring-petclinic", "dev.petclinic.liatr.io") - } - } - } - - stage('Smoke test dev') { - when { - branch 'master' - } - agent { - docker { - image 'maven:3.5.0' - args '--network=${LDOP_NETWORK_NAME}' - } - } - steps { - sh "cd regression-suite && mvn clean -B test -DPETCLINIC_URL=https://dev.petclinic.liatr.io/petclinic" - echo "Should be accessible at https://dev.petclinic.liatr.io/petclinic" - } - } - - stage('Deploy to qa') { - when { - branch 'master' - } - agent any - steps { - deployToEnvironment("ec2-user", "qa.petclinic.liatr.io", "petclinic-deploy-key", env.IMAGE, TAG, "spring-petclinic", "qa.petclinic.liatr.io") - } - } - - stage('Smoke test qa') { - when { - branch 'master' - } - agent { - docker { - image 'maven:3.5.0' - args '--network=${LDOP_NETWORK_NAME}' - } - } - steps { - sh "cd regression-suite && mvn clean -B test -DPETCLINIC_URL=https://qa.petclinic.liatr.io/petclinic" - echo "Should be accessible at https://qa.petclinic.liatr.io/petclinic" - input 'Deploy to Prod?' - } - } - - stage('Blue/Green Prod Deploy') { - when { - branch 'master' - } - agent { - dockerfile { - filename "blue-green/Dockerfile" - } - } - steps { - withCredentials([ - usernamePassword(credentialsId: 'aws', usernameVariable: 'AWS_ACCESS_KEY_ID', passwordVariable: 'AWS_SECRET_ACCESS_KEY'), - file(credentialsId: 'petclinic-deploy-key', variable: 'DEPLOY_KEY_PATH') - ]) { - script { - sh "TAG=${TAG} blue-green/blue-green deploy" - } - } - } - } - - stage('Blue/Green Prod Regression Test') { - when { - branch 'master' - } - agent { - dockerfile { - filename "blue-green/Dockerfile" - } - } - steps { - withCredentials([ - usernamePassword(credentialsId: 'aws', usernameVariable: 'AWS_ACCESS_KEY_ID', passwordVariable: 'AWS_SECRET_ACCESS_KEY'), - file(credentialsId: 'petclinic-deploy-key', variable: 'DEPLOY_KEY_PATH') - ]) { - script { - sh "TAG=${TAG} blue-green/blue-green test" - } - } - } - } - - stage('Blue/Green Prod Toggle Load Balancer') { - when { - branch 'master' - } - agent { - dockerfile { - filename "blue-green/Dockerfile" - } - } - steps { - input "Toggle Prod Load Balancer?" - withCredentials([ - usernamePassword(credentialsId: 'aws', usernameVariable: 'AWS_ACCESS_KEY_ID', passwordVariable: 'AWS_SECRET_ACCESS_KEY'), - file(credentialsId: 'petclinic-deploy-key', variable: 'DEPLOY_KEY_PATH') - ]) { - script { - sh "TAG=${TAG} blue-green/blue-green toggle" - } - } + sh '' } } } From d0695e713ac55d293e7f0b05722c66c096e796a1 Mon Sep 17 00:00:00 2001 From: gesparza3 Date: Wed, 8 May 2019 14:03:36 -0700 Subject: [PATCH 06/39] Added test_env image --- vm-images/test_env/config/tomcat-users.xml | 51 +++++++++++++ vm-images/test_env/config/tomcat.conf | 51 +++++++++++++ vm-images/test_env/src/ks.cfg | 87 ++++++++++++++++++++++ vm-images/test_env/test_env.sh | 9 +++ vm-images/test_env/test_env_build.json | 56 ++++++++++++++ 5 files changed, 254 insertions(+) create mode 100644 vm-images/test_env/config/tomcat-users.xml create mode 100644 vm-images/test_env/config/tomcat.conf create mode 100644 vm-images/test_env/src/ks.cfg create mode 100644 vm-images/test_env/test_env.sh create mode 100644 vm-images/test_env/test_env_build.json diff --git a/vm-images/test_env/config/tomcat-users.xml b/vm-images/test_env/config/tomcat-users.xml new file mode 100644 index 000000000..61d2b4889 --- /dev/null +++ b/vm-images/test_env/config/tomcat-users.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + diff --git a/vm-images/test_env/config/tomcat.conf b/vm-images/test_env/config/tomcat.conf new file mode 100644 index 000000000..bdfeb770a --- /dev/null +++ b/vm-images/test_env/config/tomcat.conf @@ -0,0 +1,51 @@ +# System-wide configuration file for tomcat services +# This will be loaded by systemd as an environment file, +# so please keep the syntax. For shell expansion support +# place your custom files as /etc/tomcat/conf.d/*.conf +# +# There are 2 "classes" of startup behavior in this package. +# The old one, the default service named tomcat.service. +# The new named instances are called tomcat@instance.service. +# +# Use this file to change default values for all services. +# Change the service specific ones to affect only one service. +# For tomcat.service it's /etc/sysconfig/tomcat, for +# tomcat@instance it's /etc/sysconfig/tomcat@instance. + +# This variable is used to figure out if config is loaded or not. +TOMCAT_CFG_LOADED="1" + +# In new-style instances, if CATALINA_BASE isn't specified, it will +# be constructed by joining TOMCATS_BASE and NAME. +TOMCATS_BASE="/var/lib/tomcats/" + +# Where your java installation lives +JAVA_HOME="/usr/lib/jvm/jre" + +# Where your tomcat installation lives +CATALINA_HOME="/usr/share/tomcat" + +# System-wide tmp +CATALINA_TMPDIR="/var/cache/tomcat/temp" + +# You can pass some parameters to java here if you wish to +#JAVA_OPTS="-Xminf0.1 -Xmaxf0.3" + +# Use JAVA_OPTS to set java.library.path for libtcnative.so +#JAVA_OPTS="-Djava.library.path=/usr/lib" + +# You can change your tomcat locale here +#LANG="en_US" + +# Run tomcat under the Java Security Manager +SECURITY_MANAGER="false" + +# Time to wait in seconds, before killing process +# TODO(stingray): does nothing, fix. +# SHUTDOWN_WAIT="30" + +# If you wish to further customize your tomcat environment, +# put your own definitions here +# (i.e. LD_LIBRARY_PATH for some jdbc drivers) +JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true -Xmx512m -XX:MaxPermSize=256m -XX:+UseConcMarkSweepGC" + diff --git a/vm-images/test_env/src/ks.cfg b/vm-images/test_env/src/ks.cfg new file mode 100644 index 000000000..e659d3c6c --- /dev/null +++ b/vm-images/test_env/src/ks.cfg @@ -0,0 +1,87 @@ +install +cdrom + +lang en_US.UTF-8 +keyboard us +timezone UTC + +network --bootproto=dhcp +firewall --disabled + +rootpw --plaintext packer +user --name=admin --password=admin +auth --enableshadow --passalgo=sha512 --kickstart +selinux --permissive + +text +skipx + +clearpart --all --initlabel +zerombr +autopart +bootloader --location=mbr + +firstboot --disable +reboot + +%packages --instLangs=en_US.utf8 --nobase --ignoremissing --excludedocs +@^minimal +@core + +-aic94xx-firmware +-atmel-firmware +-b43-openfwwf +-bfa-firmware +-ipw2100-firmware +-ipw2200-firmware +-ivtv-firmware +-iwl100-firmware +-iwl105-firmware +-iwl135-firmware +-iwl1000-firmware +-iwl2000-firmware +-iwl2030-firmware +-iwl3160-firmware +-iwl3945-firmware +-iwl4965-firmware +-iwl5000-firmware +-iwl5150-firmware +-iwl6000-firmware +-iwl6000g2a-firmware +-iwl6000g2b-firmware +-iwl6050-firmware +-iwl7260-firmware +-libertas-usb8388-firmware +-ql2100-firmware +-ql2200-firmware +-ql23xx-firmware +-ql2400-firmware +-ql2500-firmware +-rt61pci-firmware +-rt73usb-firmware +-xorg-x11-drv-ati-firmware +-zd1211-firmware +%end + +%post --log=/root/ks.log +SEE NEXT PICTURE!!!! The security settings of my provider does not allow this content! +%end + +%post +echo "admin ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/admin +echo "Defaults:admin !requiretty" >> /etc/sudoers.d/admin +chmod 0440 /etc/sudoers.d/admin +mkdir -pm 700 /home/admin/.ssh +cat </home/admin/.ssh/authorized_keys +ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8Y\ +Vr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdO\ +KLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7Pt\ +ixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmC\ +P3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcW\ +yLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== admin insecure public key +EOK +chmod 0600 /home/admin/.ssh/authorized_keys +chown -R admin.admin /home/admin/.ssh +yum -y update +yum -y remove linux-firmware +%end diff --git a/vm-images/test_env/test_env.sh b/vm-images/test_env/test_env.sh new file mode 100644 index 000000000..f70e56c5c --- /dev/null +++ b/vm-images/test_env/test_env.sh @@ -0,0 +1,9 @@ +# Provision tomcat +sudo yum install tomcat -y +sudo yum install tomcat-webapps tomcat-admin-webapps -y +sudo mv tomcat-users.xml /usr/share/tomcat/conf/tomcat-users.xml +sudo mv tomcat.conf /usr/share/tomcat/conf/tomcat.conf +sudo systemctl enable tomcat + +# Provision jenkins +sudo yum install maven -y diff --git a/vm-images/test_env/test_env_build.json b/vm-images/test_env/test_env_build.json new file mode 100644 index 000000000..d511167c3 --- /dev/null +++ b/vm-images/test_env/test_env_build.json @@ -0,0 +1,56 @@ +{ + "variables": { + "file": "http://mirrors.ocf.berkeley.edu/centos/7.6.1810/isos/x86_64/CentOS-7-x86_64-Minimal-1810.iso", + "checksum": "bd43d41e01c2a46b3cb23eb9139dce4b", + "type": "md5", + "non_gui": "false" + }, + "builders": [ + { + "type": "virtualbox-iso", + "iso_url": "{{ user `file` }}", + "iso_checksum": "{{ user `checksum` }}", + "iso_checksum_type": "md5", + "headless": "{{ user `non_gui` }}", + "output_directory": "builds", + "vm_name": "Tomcat-CentOS7", + "guest_os_type": "RedHat_64", + "disk_size": "10240", + "vboxmanage": [ + ["modifyvm", "{{.Name}}", "--memory", "2048"], + ["modifyvm", "{{.Name}}", "--cpus", "2"], + ["modifyvm", "{{.Name}}", "--audio", "none"], + ["modifyvm", "{{.Name}}", "--usb", "off"] + ], + "http_directory": "src", + "boot_wait": "5s", + "boot_command": [ + " text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg" + ], + "ssh_username": "admin", + "ssh_password": "admin", + "ssh_port": 22, + "ssh_wait_timeout": "10000s", + "guest_additions_path": "disable", + "shutdown_command": "echo 'admin' | sudo -S /sbin/halt -h -p" + } + ], + "provisioners": [ + { + "type": "file", + "source": "config/tomcat-users.xml", + "destination": "~/tomcat-users.xml" + }, + { + "type": "file", + "source": "config/tomcat.conf", + "destination": "~/tomcat.conf" + }, + { + "type": "shell", + "scripts": [ + "test_env.sh" + ] + } + ] +} From 31cc576412581544921e83e615e5cfd8a2a7f36a Mon Sep 17 00:00:00 2001 From: gesparza3 Date: Wed, 8 May 2019 14:13:12 -0700 Subject: [PATCH 07/39] Updated Jenkinsfile for pipeline --- Jenkinsfile | 2 +- vm-images/test_env/test_env_build.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0960fbbbf..691468166 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,7 +11,7 @@ pipeline { } } steps { - sh '' + sh 'mvn test' } } stage('Deploy to Artifactory') { diff --git a/vm-images/test_env/test_env_build.json b/vm-images/test_env/test_env_build.json index d511167c3..977740c65 100644 --- a/vm-images/test_env/test_env_build.json +++ b/vm-images/test_env/test_env_build.json @@ -13,7 +13,7 @@ "iso_checksum_type": "md5", "headless": "{{ user `non_gui` }}", "output_directory": "builds", - "vm_name": "Tomcat-CentOS7", + "vm_name": "Test-env-CentOS7", "guest_os_type": "RedHat_64", "disk_size": "10240", "vboxmanage": [ From 21635588f7786e5afd4140986724512d9e1fd12e Mon Sep 17 00:00:00 2001 From: gesparza3 Date: Wed, 8 May 2019 14:33:20 -0700 Subject: [PATCH 08/39] Added git to test env --- vm-images/test_env/test_env.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vm-images/test_env/test_env.sh b/vm-images/test_env/test_env.sh index f70e56c5c..a31864160 100644 --- a/vm-images/test_env/test_env.sh +++ b/vm-images/test_env/test_env.sh @@ -7,3 +7,6 @@ sudo systemctl enable tomcat # Provision jenkins sudo yum install maven -y + +# Install git +sudo yum install git -y From c111877e5d8ba6963c822e187a820ce4f1c9c753 Mon Sep 17 00:00:00 2001 From: Jordan A Date: Wed, 8 May 2019 16:04:31 -0700 Subject: [PATCH 09/39] commented out agent --- Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 691468166..7a63d36c1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,11 +5,13 @@ pipeline { stages { stage('Test') { + /* agent { node { label 'tester' } } + */ steps { sh 'mvn test' } From a20db52cca985e26fdbbbf1fb3da3068e45d5de3 Mon Sep 17 00:00:00 2001 From: Jordan A Date: Wed, 8 May 2019 16:07:23 -0700 Subject: [PATCH 10/39] removed all slaves --- Jenkinsfile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7a63d36c1..89663277a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,6 @@ #!/bin/env groovy pipeline { - agent none + agent any stages { @@ -17,24 +17,30 @@ pipeline { } } stage('Deploy to Artifactory') { + /* agent { node { label 'tester' } } + */ steps { - sh '' + // sh '' + echo 'NOT YET IMPLEMENTED' } } stage('Deploy to QA') { + /* agent { node { label 'tester' } } + */ steps { - sh '' + //sh '' + echo 'NOT YET IMPLEMENTED' } } } From 02fd19e324a05d9a328e59130dc86f14b3c1a570 Mon Sep 17 00:00:00 2001 From: Jordan A Date: Wed, 8 May 2019 17:08:47 -0700 Subject: [PATCH 11/39] Add artifactory distribution to pom --- pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pom.xml b/pom.xml index 31725653e..805331570 100644 --- a/pom.xml +++ b/pom.xml @@ -420,6 +420,12 @@ + + snapshots + localhost.localdomain-snapshots + http://192.168.0.49:8081/artifactory/libs-snapshot-local + + demopetclinic From bf68821935f46c9cf5e016b5ebb063899374aa1b Mon Sep 17 00:00:00 2001 From: Jordan A Date: Wed, 8 May 2019 20:43:19 -0700 Subject: [PATCH 12/39] change ip of artifactory server --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 805331570..7c948708d 100644 --- a/pom.xml +++ b/pom.xml @@ -423,7 +423,7 @@ snapshots localhost.localdomain-snapshots - http://192.168.0.49:8081/artifactory/libs-snapshot-local + http://10.0.0.97:8081/artifactory/libs-snapshot-local