diff --git a/jenkinsfiles/full-demo b/jenkinsfiles/full-demo deleted file mode 100644 index d90384971..000000000 --- a/jenkinsfiles/full-demo +++ /dev/null @@ -1,122 +0,0 @@ -pipeline { - agent none - stages { - stage('Build') { - agent { - docker { - image 'maven:3.5.0' - args '-e INITIAL_ADMIN_USER -e INITIAL_ADMIN_PASSWORD --network=${LDOP_NETWORK_NAME}' - } - } - steps { - configFileProvider( - [configFile(fileId: 'nexus', variable: 'MAVEN_SETTINGS')]) { - sh 'mvn -s $MAVEN_SETTINGS clean deploy -DskipTests=true -B' - } - } - } - stage('Sonar') { - 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}' - } - } - 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}' - } - } - stage('Build container') { - agent any - steps { - sh 'docker build -t petclinic-tomcat .' - } - } - 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 petclinic-tomcat' - } - } - stage('Smoke-Test & OWASP Security Scan') { - agent { - docker { - image 'maven:3.5.0' - args '--network=${LDOP_NETWORK_NAME}' - } - } - steps { - sh "cd regression-suite" - sh "mvn clean -B test -DPETCLINIC_URL=http://petclinic-tomcat:8080/petclinic/" - } - } - stage('Stop local container') { - agent any - steps { - sh 'docker rm -f petclinic-tomcat-temp || true' - } - } - stage('Deploy to dev') { - agent any - steps { - sh 'docker rm -f dev-petclinic || true' - sh 'docker run --label "traefik.backend=dev-petclinic" --label "traefik.frontend.rule=Host:dev.petclinic.docker.localhost" -d --network=${LDOP_NETWORK_NAME} --name dev-petclinic petclinic-tomcat' - } - } - stage('Smoke test dev') { - agent { - docker { - image 'maven:3.5.0' - args '--network=${LDOP_NETWORK_NAME}' - } - } - steps { - sh "cd regression-suite" - sh "mvn clean -B test -DPETCLINIC_URL=http://dev-petclinic:8080/petclinic/" - echo "Should be accessible at http://localhost:18888/petclinic" - } - } - stage('Deploy to qa') { - agent any - steps { - sh 'docker rm -f qa-petclinic || true' - sh 'docker run --label "traefik.backend=qa-petclinic" --label "traefik.frontend.rule=Host:qa.petclinic.docker.localhost" -d --network=${LDOP_NETWORK_NAME} --name qa-petclinic petclinic-tomcat' - } - } - stage('Smoke test qa') { - agent { - docker { - image 'maven:3.5.0' - args '--network=${LDOP_NETWORK_NAME}' - } - } - steps { - sh "cd regression-suite" - sh "mvn clean -B test -DPETCLINIC_URL=http://qa-petclinic:8080/petclinic/" - echo "Should be accessible at http://localhost:18889/petclinic" - input 'Deploy to Prod?' - } - } - stage('Deploy to prod') { - agent any - steps { - sh 'docker rm -f prod-petclinic || true' - sh 'docker run --label "traefik.backend=prod-petclinic" --label "traefik.frontend.rule=Host:prod.petclinic.docker.localhost" -d --network=${LDOP_NETWORK_NAME} --name prod-petclinic petclinic-tomcat' - } - } - stage('Smoke Test prod') { - agent { - docker { - image 'maven:3.5.0' - args '--network=${LDOP_NETWORK_NAME}' - } - } - steps { - sh "cd regression-suite" - sh "mvn clean -B test -DPETCLINIC_URL=http://prod-petclinic:8080/petclinic/" - echo "Should be accessible at http://localhost:18890/petclinic" - } - } - } -} diff --git a/jenkinsfiles/full-demo/full-demo b/jenkinsfiles/full-demo/full-demo new file mode 100644 index 000000000..3b366d9aa --- /dev/null +++ b/jenkinsfiles/full-demo/full-demo @@ -0,0 +1,154 @@ +pipeline { + agent none + stages { + stage('Build') { + agent { + docker { + image 'maven:3.5.0' + args '-e INITIAL_ADMIN_USER -e INITIAL_ADMIN_PASSWORD --network=${LDOP_NETWORK_NAME}' + } + } + steps { + configFileProvider( + [configFile(fileId: 'nexus', variable: 'MAVEN_SETTINGS')]) { + sh 'mvn -s $MAVEN_SETTINGS clean deploy -DskipTests=true -B' + } + } + } + stage('Sonar') { + 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}' + } + } + 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}' + } + } + stage('Build container') { + agent any + steps { + sh 'docker build -t petclinic-tomcat .' + } + } + 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 petclinic-tomcat' + } + } + stage('Smoke-Test & OWASP Security Scan') { + agent { + docker { + image 'maven:3.5.0' + args '--network=${LDOP_NETWORK_NAME}' + } + } + steps { + sh "cd regression-suite" + sh "mvn clean -B test -DPETCLINIC_URL=http://petclinic-tomcat:8080/petclinic/" + } + } + stage('Stop local container') { + agent any + steps { + sh 'docker rm -f petclinic-tomcat-temp || true' + } + } + stage('Deploy to dev') { + agent any + steps { + sh 'docker rm -f dev-petclinic || true' + sh 'docker run --label "traefik.enable=true" --label "traefik.backend=dev-petclinic" --label "traefik.frontend.rule=Host:dev.petclinic.localhost" -d --network=${LDOP_NETWORK_NAME} --name dev-petclinic petclinic-tomcat' + } + } + stage('Smoke test dev') { + agent { + docker { + image 'maven:3.5.0' + args '--network=${LDOP_NETWORK_NAME}' + } + } + steps { + sh "cd regression-suite" + sh "mvn clean -B test -DPETCLINIC_URL=http://dev-petclinic:8080/petclinic/" + echo "Should be accessible at http://localhost:18888/petclinic" + } + } + stage('Deploy to qa') { + agent any + steps { + sh 'docker rm -f qa-petclinic || true' + sh 'docker run --label "traefik.enable=true" --label "traefik.backend=qa-petclinic" --label "traefik.frontend.rule=Host:qa.petclinic.localhost" -d --network=${LDOP_NETWORK_NAME} --name qa-petclinic petclinic-tomcat' + } + } + stage('Smoke test qa') { + agent { + docker { + image 'maven:3.5.0' + args '--network=${LDOP_NETWORK_NAME}' + } + } + steps { + sh "cd regression-suite" + sh "mvn clean -B test -DPETCLINIC_URL=http://qa-petclinic:8080/petclinic/" + echo "Should be accessible at http://localhost:18889/petclinic" + input 'Deploy to Prod?' + } + } + stage('Deploy to ProdA-Green') { + agent any + steps { + sh 'docker rm -f proda-petclinic-green || true' + sh 'docker run --label "traefik.enable=true" --label "traefik.backend=prod-petclinic" --label "traefik.frontend.rule=Host:prod.petclinic.localhost" -d --network=${LDOP_NETWORK_NAME} --name proda-petclinic-green petclinic-tomcat' + } + } + stage('Smoke test ProdA-Green') { + agent { + docker { + image 'maven:3.5.0' + args '--network=${LDOP_NETWORK_NAME}' + } + } + steps { + sh "cd regression-suite" + sh "mvn clean -B test -DPETCLINIC_URL=http://proda-petclinic-green:8080/petclinic/" + } + } + stage('Deploy to ProdA') { + agent any + steps { + sh 'docker rm -f proda-petclinic || true' + sh 'docker container rename proda-petclinic-green proda-petclinic' + } + } + stage('Deploy to ProdB-Green') { + agent any + steps { + sh 'docker rm -f prodb-petclinic-green || true' + sh 'docker run --label "traefik.enable=true" --label "traefik.backend=prod-petclinic" --label "traefik.frontend.rule=Host:prod.petclinic.localhost" -d --network=${LDOP_NETWORK_NAME} --name prodb-petclinic-green petclinic-tomcat' + } + } + stage('Smoke test ProdB-Green') { + agent { + docker { + image 'maven:3.5.0' + args '--network=${LDOP_NETWORK_NAME}' + } + } + steps { + sh "cd regression-suite" + sh "mvn clean -B test -DPETCLINIC_URL=http://prodb-petclinic-green:8080/petclinic/" + } + } + stage('Deploy to ProdB') { + agent any + steps { + sh 'docker rm -f prodb-petclinic || true' + sh 'docker container rename prodb-petclinic-green prodb-petclinic' + } + } + } +}