From d5d79390bef61fd52723ef3df0d9c0091b295966 Mon Sep 17 00:00:00 2001 From: cubecc Date: Thu, 28 May 2020 12:39:03 +0800 Subject: [PATCH 001/121] dasd --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 37d9cf9..c66f97a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,7 +5,7 @@ pipeline { registry = "registry.lab.local:5000/webdemo" registryCredential = 'docker-registry-100.64.21.108' dockerImage = '' - env= "uat" + env= "dev" } tools { From 8c6adf212e264207acdf3a615ef7086df9cba81b Mon Sep 17 00:00:00 2001 From: cubecc Date: Thu, 28 May 2020 12:41:45 +0800 Subject: [PATCH 002/121] dasd --- webdemo.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/webdemo.yaml b/webdemo.yaml index e5f16c1..9d953c2 100644 --- a/webdemo.yaml +++ b/webdemo.yaml @@ -3,27 +3,27 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: webdemo + name: webdemo-dev spec: replicas: 3 selector: matchLabels: - app: webdemo + app: webdemo-dev template: metadata: labels: - app: webdemo + app: webdemo-dev spec: containers: - name: webdemo - image: registry.lab.local:5000/webdemo:latest + image: registry.lab.local:5000/webdemo-dev:latest imagePullPolicy: Always env: - name: env value: "testing" ports: - containerPort: 18080 - name: webdemo + name: webdemo-dev protocol: TCP imagePullSecrets: - name: regcred @@ -32,13 +32,13 @@ spec: apiVersion: v1 kind: Service metadata: - name: webdemo + name: webdemo-dev spec: selector: - app: webdemo + app: webdemo-dev type: NodePort ports: - - name: webdemo + - name: webdemo-dev port: 18080 - nodePort: 31234 + nodePort: 31235 From 9c25d6e9c65c3b8c8545853f05f06345c9403be4 Mon Sep 17 00:00:00 2001 From: cubecc Date: Thu, 28 May 2020 12:46:31 +0800 Subject: [PATCH 003/121] dasdsad --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index c66f97a..669b02c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ pipeline { agent any environment { - registry = "registry.lab.local:5000/webdemo" + registry = "registry.lab.local:5000/webdemo-dev" registryCredential = 'docker-registry-100.64.21.108' dockerImage = '' env= "dev" From b94d5b940c95d19d4a218d807c5b12d2134a4cc4 Mon Sep 17 00:00:00 2001 From: cubecc Date: Thu, 28 May 2020 13:42:24 +0800 Subject: [PATCH 004/121] asdad --- Jenkinsfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 669b02c..8351766 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,7 +22,7 @@ pipeline { ''' } } - + /* stage("Cloning Git") { steps{ git credentialsId: 'cube-github', url: 'git@github.com:cubecc/devop_java.git' @@ -74,6 +74,7 @@ pipeline { steps{ sh "docker rmi $registry:$BUILD_NUMBER" } - } + } + */ } } \ No newline at end of file From 409562c87ddeeb8961c9e36c4c33d89128502e65 Mon Sep 17 00:00:00 2001 From: cubecc Date: Thu, 28 May 2020 13:51:19 +0800 Subject: [PATCH 005/121] dasdd --- Jenkinsfile | 55 +---------------------------------------------------- 1 file changed, 1 insertion(+), 54 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8351766..c2560da 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,59 +22,6 @@ pipeline { ''' } } - /* - stage("Cloning Git") { - steps{ - git credentialsId: 'cube-github', url: 'git@github.com:cubecc/devop_java.git' - } - } - - stage ('Build Src') { - steps { - echo 'Start Build...' - //sh 'mvn -Dmaven.test.failure.ignore=true package' - sh 'mvn package -P${env}' - } - post { - success { - junit 'target/surefire-reports/**/*.xml' - } - } - } - - - - stage('Building image') { - steps{ - script { - dockerImage = docker.build registry + ":$BUILD_NUMBER -f Dockerfile" - } - } - - } - - stage('Push Image') { - steps{ - script { - docker.withRegistry( 'https://registry.lab.local:5000', registryCredential ) { - sh "docker tag $registry:$BUILD_NUMBER $registry:latest" - sh "docker push $registry:latest" - } - } - } - } - stage('Deploy K8') { - steps{ - sh("kubectl replace -f webdemo.yaml --force") - } - - } - - stage('Remove Unused docker image') { - steps{ - sh "docker rmi $registry:$BUILD_NUMBER" - } - } - */ + } } \ No newline at end of file From eb9774063e1cbf3756762fdd24ef549e3d602668 Mon Sep 17 00:00:00 2001 From: cubecc Date: Thu, 28 May 2020 13:55:12 +0800 Subject: [PATCH 006/121] test --- Jenkinsfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index c2560da..15976c3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,7 +19,10 @@ pipeline { sh ''' echo "PATH = ${PATH}" echo "M2_HOME = ${M2_HOME}" + echo "" ''' + + sh 'printenv' } } From 611bed4344ddf00484d85373e00e1108f55abe04 Mon Sep 17 00:00:00 2001 From: cubecc Date: Thu, 28 May 2020 16:28:17 +0800 Subject: [PATCH 007/121] dad --- Jenkinsfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 15976c3..37b72af 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,6 +14,12 @@ pipeline { stages { + stage ('cleanup'){ + steps{ + deleteDir() + } + } + stage ('Initialize') { steps { sh ''' From dacd81651b47c5b9899700a0e1ca65e4c1047637 Mon Sep 17 00:00:00 2001 From: cubecc Date: Thu, 28 May 2020 16:30:05 +0800 Subject: [PATCH 008/121] dasd --- Jenkinsfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 37b72af..95a6853 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,12 +13,13 @@ pipeline { } stages { - +/* stage ('cleanup'){ steps{ deleteDir() } } +*/ stage ('Initialize') { steps { @@ -28,7 +29,7 @@ pipeline { echo "" ''' - sh 'printenv' + } } From fc4adae98b18b32e5f425f24e8b718c878643429 Mon Sep 17 00:00:00 2001 From: cubecc Date: Thu, 28 May 2020 16:45:25 +0800 Subject: [PATCH 009/121] dasd --- Jenkinsfile | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 95a6853..ad0c29a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,13 +13,13 @@ pipeline { } stages { -/* - stage ('cleanup'){ + + stage ('clean before working'){ steps{ deleteDir() } } -*/ + stage ('Initialize') { steps { @@ -27,11 +27,23 @@ pipeline { echo "PATH = ${PATH}" echo "M2_HOME = ${M2_HOME}" echo "" - ''' - - + ''' } } + + stage('Build') { + agent { + docker { + reuseNode true + image 'maven:3.6.3-jdk-8' + } + } + steps { + withMaven(options: [findbugsPublisher(), junitPublisher(ignoreAttachments: false)]) { + sh 'mvn clean findbugs:findbugs package' + } + } + } } } \ No newline at end of file From 9f2ebb0710e587dc73ec39f0b0884bdbc4796265 Mon Sep 17 00:00:00 2001 From: cubecc Date: Thu, 28 May 2020 16:54:48 +0800 Subject: [PATCH 010/121] dad --- Jenkinsfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index ad0c29a..e113f48 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,9 @@ pipeline { - agent any + agent { + node { + label 'docker' + } + } environment { registry = "registry.lab.local:5000/webdemo-dev" From eaea80954995fc31c37c08ba6c5785ffa8d65f8a Mon Sep 17 00:00:00 2001 From: cubecc Date: Thu, 28 May 2020 18:16:00 +0800 Subject: [PATCH 011/121] dasd --- Jenkinsfile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e113f48..2a3b741 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,7 @@ pipeline { agent { node { - label 'docker' + label 'kubernetes' } } @@ -31,11 +31,12 @@ pipeline { echo "PATH = ${PATH}" echo "M2_HOME = ${M2_HOME}" echo "" - ''' + ''' + sh 'k get pod' } } - + /* stage('Build') { agent { docker { @@ -49,5 +50,6 @@ pipeline { } } } + */ } } \ No newline at end of file From a5252f41b47dc49dd9d9526daf56fa96b852727f Mon Sep 17 00:00:00 2001 From: cubecc Date: Thu, 28 May 2020 18:23:46 +0800 Subject: [PATCH 012/121] dadad --- Jenkinsfile | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2a3b741..125c909 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,9 +1,9 @@ pipeline { - agent { - node { - label 'kubernetes' - } - } + agent { + docker { + image 'maven:3.6.3-jdk-8' + } + } environment { registry = "registry.lab.local:5000/webdemo-dev" @@ -31,12 +31,11 @@ pipeline { echo "PATH = ${PATH}" echo "M2_HOME = ${M2_HOME}" echo "" - ''' - sh 'k get pod' + ''' } } - /* + stage('Build') { agent { docker { @@ -50,6 +49,6 @@ pipeline { } } } - */ + } } \ No newline at end of file From 224e0f4a0c64b19d3b327376a71fa63a8b2f1a99 Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 09:43:14 +0800 Subject: [PATCH 013/121] sda --- Jenkinsfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 125c909..19da945 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,9 +1,9 @@ pipeline { - agent { - docker { - image 'maven:3.6.3-jdk-8' - } + agent { + node { + label ‘docker‘ } + } environment { registry = "registry.lab.local:5000/webdemo-dev" From 87082d3e68689803b39896b1ef7ae4961f208934 Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 09:45:25 +0800 Subject: [PATCH 014/121] dasd --- Jenkinsfile | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 19da945..d8c594b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,9 +1,5 @@ pipeline { - agent { - node { - label ‘docker‘ - } - } + agent any environment { registry = "registry.lab.local:5000/webdemo-dev" From 0940a24a60f7b466fbd0941ab477b3292265af87 Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 09:49:49 +0800 Subject: [PATCH 015/121] dsadd --- Jenkinsfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d8c594b..3e326ca 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,10 @@ pipeline { - agent any + agent { + docker { + reuseNode true + image 'maven:3.6.3-jdk-8' + } + } environment { registry = "registry.lab.local:5000/webdemo-dev" From 7d63f78cb26a5d8b50b681e02e258caeca54d039 Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 09:54:34 +0800 Subject: [PATCH 016/121] dsad --- Jenkinsfile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3e326ca..debadab 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,10 +1,5 @@ pipeline { - agent { - docker { - reuseNode true - image 'maven:3.6.3-jdk-8' - } - } + agent any environment { registry = "registry.lab.local:5000/webdemo-dev" @@ -40,7 +35,6 @@ pipeline { stage('Build') { agent { docker { - reuseNode true image 'maven:3.6.3-jdk-8' } } From 10a3a4b71863404aedf40bba3bb5b16adf282d3e Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 12:26:31 +0800 Subject: [PATCH 017/121] dsad --- Jenkinsfile | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index debadab..b102e70 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,6 +6,10 @@ pipeline { registryCredential = 'docker-registry-100.64.21.108' dockerImage = '' env= "dev" + //IMAGE = readMavenPom().getArtifactId() + //VERSION = readMavenPom().getVersion() + IMAGE = "registry.lab.local:5000/webdemo-dev" + VERSION = ${BUILD_NUMBER} } tools { @@ -32,18 +36,30 @@ pipeline { } - stage('Build') { - agent { - docker { - image 'maven:3.6.3-jdk-8' - } - } - steps { - withMaven(options: [findbugsPublisher(), junitPublisher(ignoreAttachments: false)]) { - sh 'mvn clean findbugs:findbugs package' - } - } + stage('Build & Test') { + steps { + sh 'mvn clean findbugs:findbugs package' + } } + stage('QA') { + steps { + //sh ‘mvn sonar:sonar -Dsonar.login=$SONAR_PSW‘ + } + } + + stage('Build & Publish Images') { + + steps { + sh ''' + docker build -t ${IMAGE}:${VERSION} . + docker tag ${IMAGE} ${IMAGE}:${VERSION} + docker push ${IMAGE}:${VERSION} + ''' + } + } + + //stage('Build and Publish Image') { + //} } } \ No newline at end of file From f0673bc5904130807392150df2b7516f7b3fd45c Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 12:29:14 +0800 Subject: [PATCH 018/121] dasd --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b102e70..240cf6f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,7 +9,7 @@ pipeline { //IMAGE = readMavenPom().getArtifactId() //VERSION = readMavenPom().getVersion() IMAGE = "registry.lab.local:5000/webdemo-dev" - VERSION = ${BUILD_NUMBER} + VERSION = "${BUILD_NUMBER}" } tools { From d1f9933f4d53507b0d856dc4a6bd316c4a194522 Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 12:31:25 +0800 Subject: [PATCH 019/121] dadasd --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 240cf6f..7b08478 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -44,7 +44,8 @@ pipeline { stage('QA') { steps { - //sh ‘mvn sonar:sonar -Dsonar.login=$SONAR_PSW‘ + sh 'call sonar for qa (TODO)' + //sh 'mvn sonar:sonar -Dsonar.login=$SONAR_PSW' } } From 0379aedc3b423bd3813c89640bf3a6004dc0c4e3 Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 12:32:35 +0800 Subject: [PATCH 020/121] dsad --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7b08478..860542f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -38,7 +38,7 @@ pipeline { stage('Build & Test') { steps { - sh 'mvn clean findbugs:findbugs package' + sh 'mvn clean package' } } From 8c0c09d13b6c1b01dfbcaa3f528e8788b27001cc Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 12:35:14 +0800 Subject: [PATCH 021/121] dasd --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 860542f..57e74e8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -38,7 +38,7 @@ pipeline { stage('Build & Test') { steps { - sh 'mvn clean package' + sh 'mvn clean package -P${env}' } } From 4654925af707999889790c972da892b3c9ba0a3d Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 12:37:07 +0800 Subject: [PATCH 022/121] dad --- Jenkinsfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 57e74e8..4538d72 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,11 +18,11 @@ pipeline { stages { - stage ('clean before working'){ - steps{ - deleteDir() - } - } + //stage ('clean before working'){ + // steps{ + // deleteDir() + // } + //} stage ('Initialize') { From af8ec5e0adbf511e233c6521fa7f3b5f6484e81c Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 12:39:29 +0800 Subject: [PATCH 023/121] dad --- Jenkinsfile | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4538d72..4f53b81 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,13 +17,6 @@ pipeline { } stages { - - //stage ('clean before working'){ - // steps{ - // deleteDir() - // } - //} - stage ('Initialize') { steps { @@ -44,7 +37,7 @@ pipeline { stage('QA') { steps { - sh 'call sonar for qa (TODO)' + sh 'call sonar for qa - TODO' //sh 'mvn sonar:sonar -Dsonar.login=$SONAR_PSW' } } @@ -61,6 +54,12 @@ pipeline { } //stage('Build and Publish Image') { - //} + //} + + //stage ('clean after working'){ + // steps{ + // deleteDir() + // } + //} } } \ No newline at end of file From 9c77a0f9d99f4c01c47cddfd84dfff28c6ecd080 Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 12:40:15 +0800 Subject: [PATCH 024/121] dad --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4f53b81..34bf026 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -37,7 +37,7 @@ pipeline { stage('QA') { steps { - sh 'call sonar for qa - TODO' + echo 'call sonar for qa (TODO)' //sh 'mvn sonar:sonar -Dsonar.login=$SONAR_PSW' } } From 516e94a4baf97f5baf5997f0366d2f8ce3fe587f Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 14:10:31 +0800 Subject: [PATCH 025/121] dasd --- Jenkinsfile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 34bf026..9188c0a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -46,9 +46,13 @@ pipeline { steps { sh ''' - docker build -t ${IMAGE}:${VERSION} . - docker tag ${IMAGE} ${IMAGE}:${VERSION} - docker push ${IMAGE}:${VERSION} + + docker.withRegistry( 'https://registry.lab.local:5000', registryCredential ) { + docker build -t ${IMAGE}:${VERSION} . + docker tag ${IMAGE} ${IMAGE}:${VERSION} + docker push ${IMAGE}:${VERSION} + } + ''' } } From 343a4ed7d7a63c34501c1ffcfdc49f7f33a4d7cc Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 14:12:37 +0800 Subject: [PATCH 026/121] czcx --- Jenkinsfile | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9188c0a..d65660d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -45,15 +45,17 @@ pipeline { stage('Build & Publish Images') { steps { - sh ''' - - docker.withRegistry( 'https://registry.lab.local:5000', registryCredential ) { - docker build -t ${IMAGE}:${VERSION} . - docker tag ${IMAGE} ${IMAGE}:${VERSION} - docker push ${IMAGE}:${VERSION} - } - - ''' + docker.withRegistry( 'https://registry.lab.local:5000', registryCredential ) { + sh ''' + + + docker build -t ${IMAGE}:${VERSION} . + docker tag ${IMAGE} ${IMAGE}:${VERSION} + docker push ${IMAGE}:${VERSION} + + + ''' + } } } From 688c66afe1c60e3aaea4cb5d02e8e90361321413 Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 14:14:20 +0800 Subject: [PATCH 027/121] dasdsd --- Jenkinsfile | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d65660d..3d18b3a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -45,17 +45,19 @@ pipeline { stage('Build & Publish Images') { steps { - docker.withRegistry( 'https://registry.lab.local:5000', registryCredential ) { - sh ''' - - - docker build -t ${IMAGE}:${VERSION} . - docker tag ${IMAGE} ${IMAGE}:${VERSION} - docker push ${IMAGE}:${VERSION} - - - ''' - } + script { + docker.withRegistry( 'https://registry.lab.local:5000', registryCredential ) { + sh ''' + + + docker build -t ${IMAGE}:${VERSION} . + docker tag ${IMAGE} ${IMAGE}:${VERSION} + docker push ${IMAGE}:${VERSION} + + + ''' + } + } } } From 61bce331fd4a5d0bcce885fca694654fd4d50d0f Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 14:23:43 +0800 Subject: [PATCH 028/121] dasd --- Jenkinsfile | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3d18b3a..aa22ddc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,7 @@ pipeline { environment { registry = "registry.lab.local:5000/webdemo-dev" registryCredential = 'docker-registry-100.64.21.108' - dockerImage = '' + //dockerImage = '' env= "dev" //IMAGE = readMavenPom().getArtifactId() //VERSION = readMavenPom().getVersion() @@ -47,20 +47,23 @@ pipeline { steps { script { docker.withRegistry( 'https://registry.lab.local:5000', registryCredential ) { - sh ''' - - + sh ''' docker build -t ${IMAGE}:${VERSION} . - docker tag ${IMAGE} ${IMAGE}:${VERSION} - docker push ${IMAGE}:${VERSION} - - + docker tag ${IMAGE}:${VERSION} ${IMAGE}:latest + docker push ${IMAGE}:latest ''' } } } } + stage('Deploy to K8') { + steps{ + sh("kubectl replace -f webdemo.yaml --force") + } + + } + //stage('Build and Publish Image') { //} From 97eac082bbda1c192e386d77a4ca5c016bd65bed Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 15:59:22 +0800 Subject: [PATCH 029/121] dasdad --- Jenkinsfile | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index aa22ddc..c656df0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -33,6 +33,11 @@ pipeline { steps { sh 'mvn clean package -P${env}' } + post { + success { + junit 'target/surefire-reports/**/*.xml' + } + } } stage('QA') { @@ -60,8 +65,7 @@ pipeline { stage('Deploy to K8') { steps{ sh("kubectl replace -f webdemo.yaml --force") - } - + } } //stage('Build and Publish Image') { @@ -72,5 +76,30 @@ pipeline { // deleteDir() // } //} + + + post { + always { + echo 'echo 'post status : clearup workspace' + deleteDir() /* clean up our workspace */ + } + success { + echo 'post status : success' + } + unstable { + echo 'post status : unstable' + } + failure { + echo 'post status : failure' + //mail to: 'alex.cc.chan@jos.com', + //subject: "Failed Pipeline: ${currentBuild.fullDisplayName}", + //body: "Something is wrong with ${env.BUILD_URL}" + } + changed { + echo 'post status : changed' + } + + } + } } \ No newline at end of file From 66157f477ad6caf962aa290328ba94a4d12d5b9e Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 16:00:34 +0800 Subject: [PATCH 030/121] dasdsd --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index c656df0..c0d5eb2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -80,7 +80,7 @@ pipeline { post { always { - echo 'echo 'post status : clearup workspace' + echo 'post status : clearup workspace' deleteDir() /* clean up our workspace */ } success { From 2d5f478bc91db53ab22bffa8b25f0bfd0c30275d Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 16:02:12 +0800 Subject: [PATCH 031/121] dasdd --- Jenkinsfile | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c0d5eb2..f5df1ce 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -76,30 +76,28 @@ pipeline { // deleteDir() // } //} - - - post { - always { - echo 'post status : clearup workspace' - deleteDir() /* clean up our workspace */ - } - success { - echo 'post status : success' - } - unstable { - echo 'post status : unstable' - } - failure { - echo 'post status : failure' - //mail to: 'alex.cc.chan@jos.com', - //subject: "Failed Pipeline: ${currentBuild.fullDisplayName}", - //body: "Something is wrong with ${env.BUILD_URL}" - } - changed { - echo 'post status : changed' - } - - } } + post { + always { + echo 'post status : clearup workspace' + deleteDir() /* clean up our workspace */ + } + success { + echo 'post status : success' + } + unstable { + echo 'post status : unstable' + } + failure { + echo 'post status : failure' + //mail to: 'alex.cc.chan@jos.com', + //subject: "Failed Pipeline: ${currentBuild.fullDisplayName}", + //body: "Something is wrong with ${env.BUILD_URL}" + } + changed { + echo 'post status : changed' + } + + } } \ No newline at end of file From d65a23e775472c0be43fa930cffa5493fce2fc3a Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 16:09:49 +0800 Subject: [PATCH 032/121] dadad --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f5df1ce..73d7d94 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,6 +3,7 @@ pipeline { environment { registry = "registry.lab.local:5000/webdemo-dev" + registryUrl = 'https://100.64.21.108:5000' registryCredential = 'docker-registry-100.64.21.108' //dockerImage = '' env= "dev" @@ -51,7 +52,7 @@ pipeline { steps { script { - docker.withRegistry( 'https://registry.lab.local:5000', registryCredential ) { + docker.withRegistry( ${registryUrl}, ${registryCredential} ) { sh ''' docker build -t ${IMAGE}:${VERSION} . docker tag ${IMAGE}:${VERSION} ${IMAGE}:latest From 6981cd1c9cf4c9a04089dc3e8f11d67e632143c1 Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 16:11:45 +0800 Subject: [PATCH 033/121] dsada --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 73d7d94..4efbd56 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -52,7 +52,7 @@ pipeline { steps { script { - docker.withRegistry( ${registryUrl}, ${registryCredential} ) { + docker.withRegistry( registryUrl, registryCredential ) { sh ''' docker build -t ${IMAGE}:${VERSION} . docker tag ${IMAGE}:${VERSION} ${IMAGE}:latest From c2ce56ffa63696ee6789d146fabd661d59e1ff99 Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 16:42:14 +0800 Subject: [PATCH 034/121] dad --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4efbd56..f346812 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,7 +3,8 @@ pipeline { environment { registry = "registry.lab.local:5000/webdemo-dev" - registryUrl = 'https://100.64.21.108:5000' + //registryUrl = 'https://100.64.21.108:5000' + registryUrl = 'https://registry.lab.local:5000' registryCredential = 'docker-registry-100.64.21.108' //dockerImage = '' env= "dev" From 3801a94b8d3977f93c74459b5753592b7122af33 Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 16:58:31 +0800 Subject: [PATCH 035/121] dad --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f346812..93f6fe2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,7 +5,8 @@ pipeline { registry = "registry.lab.local:5000/webdemo-dev" //registryUrl = 'https://100.64.21.108:5000' registryUrl = 'https://registry.lab.local:5000' - registryCredential = 'docker-registry-100.64.21.108' + //registryCredential = 'docker-registry-100.64.21.108' + registryCredential = 'docker-registry-login' //dockerImage = '' env= "dev" //IMAGE = readMavenPom().getArtifactId() From cec4e97953bacf9034a04fff1af1e0ba08d79fd2 Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 18:26:04 +0800 Subject: [PATCH 036/121] dsad --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 93f6fe2..3eff73c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,8 +5,8 @@ pipeline { registry = "registry.lab.local:5000/webdemo-dev" //registryUrl = 'https://100.64.21.108:5000' registryUrl = 'https://registry.lab.local:5000' - //registryCredential = 'docker-registry-100.64.21.108' - registryCredential = 'docker-registry-login' + registryCredential = 'docker-registry-100.64.21.108' + //registryCredential = 'docker-registry-login' //dockerImage = '' env= "dev" //IMAGE = readMavenPom().getArtifactId() From 64ee995c9d9bb7f19e3b61bf4320bb54e6bab3a6 Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 1 Jun 2020 18:28:43 +0800 Subject: [PATCH 037/121] dasds --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3eff73c..93f6fe2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,8 +5,8 @@ pipeline { registry = "registry.lab.local:5000/webdemo-dev" //registryUrl = 'https://100.64.21.108:5000' registryUrl = 'https://registry.lab.local:5000' - registryCredential = 'docker-registry-100.64.21.108' - //registryCredential = 'docker-registry-login' + //registryCredential = 'docker-registry-100.64.21.108' + registryCredential = 'docker-registry-login' //dockerImage = '' env= "dev" //IMAGE = readMavenPom().getArtifactId() From a8188cae4983887b3a87f481d334f139292350ea Mon Sep 17 00:00:00 2001 From: cubecc Date: Tue, 2 Jun 2020 17:28:42 +0800 Subject: [PATCH 038/121] dad --- Jenkinsfile | 22 ++++++- config/dev/config.properties | 2 +- config/uat/config.properties | 2 +- create_table.sql | 19 ++++++ pom.xml | 15 ++++- .../webDemo/controller/HelloController.java | 21 +++++++ .../webDemo/controller/WebUserController.java | 59 +++++++++++++++++++ .../java/com/cube/webDemo/dao/WebUserDao.java | 15 +++++ .../java/com/cube/webDemo/entity/WebUser.java | 57 ++++++++++++++++++ src/main/resources/application.yaml | 19 +++++- src/main/resources/templates/login.html | 21 +++++++ src/main/resources/templates/users.html | 29 +++++++++ .../controller/WebUserControllerTest.java | 27 +++++++++ 13 files changed, 299 insertions(+), 9 deletions(-) create mode 100644 create_table.sql create mode 100644 src/main/java/com/cube/webDemo/controller/WebUserController.java create mode 100644 src/main/java/com/cube/webDemo/dao/WebUserDao.java create mode 100644 src/main/java/com/cube/webDemo/entity/WebUser.java create mode 100644 src/main/resources/templates/login.html create mode 100644 src/main/resources/templates/users.html create mode 100644 src/test/java/com/cube/webDemo/controller/WebUserControllerTest.java diff --git a/Jenkinsfile b/Jenkinsfile index 93f6fe2..33ad92b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,6 +20,20 @@ pipeline { } stages { + + stage('User Input') { + steps { + timeout(60) { + script { + approvalMap = input id: 'test', message: 'Hello', ok: 'Proceed?', parameters: [choice(choices: 'apple\npear\norange', description: 'Select a fruit for this build', name: 'FRUIT'), string(defaultValue: '', description: '', name: 'myparam')], submitter: 'user1,user2,group1', submitterParameter: 'APPROVER' + } + } + + echo "This build was approved by: ${approvalMap['APPROVER']}" + echo "This build is brought to you today by the fruit: ${approvalMap['FRUIT']}" + echo "This is myparam: ${approvalMap['myparam']}" + } + } stage ('Initialize') { steps { @@ -30,8 +44,7 @@ pipeline { ''' } } - - + stage('Build & Test') { steps { sh 'mvn clean package -P${env}' @@ -71,6 +84,11 @@ pipeline { } } + stage('Post test') { + steps{ + echo 'ping' + } + } //stage('Build and Publish Image') { //} diff --git a/config/dev/config.properties b/config/dev/config.properties index 5fe6460..d04ddba 100644 --- a/config/dev/config.properties +++ b/config/dev/config.properties @@ -1,2 +1,2 @@ -env.name=cube-dev-${env} +env.name=cube-dev secret.password=ENC(jkYAjTJWtD6vNMDL1gsQantyRxLyy7dJKYw/IGu5mdzsxF2Zdcrbe7hevZmNm8+4VAVazz/Hp4DtgG2tmGVQUv1FwCsvNoqzESWHjRxqEAxAvmF3nA7YfaNs7UX8l1wsFD3luhfdp6OIFXjr0eSOvafLbhVeR/u6fs9vbcfF48dDcOtRS9Tr8fMsfN+F2Yds3QxtM73Pg39C417cLY86FNKkSroX6Pwoifl1ihor0804OphvzkBM6mftjwZ/wI2efYdPOae8aNd/OUy1vNTj/Hwp+ZhTxpWEFk1Zk2Q6UxekmL7A0XDhkoONYGC1p+pEbG4n6UD2VkTNduHM4AcOHw+V/zRSRww8yw0Onw0gYYQc4UyszRZOr6jGL+ABqtfkYyhL8zi0kXPAcrEBlLCWlA1pFT4NblLfzoDiNIRUtynR5ONH8I51ElYTdMjhO8Fh6PE9/+S9eCIxbhaIbAkL5jkw/53bk1fFYZkXO4ZloX8dJWS3yh6/XMEF4cjIrBwMtm6lbClFCBoNa+uZ99DwY2S+/sXVDsrtxQRoNcxf8F6qklknUfLs772J3rdrKl5NNWvu6EGzepaRoTTckev1XLHtw89NsI+To6z+dm6iSFDu1nuAecJlUNaQEAN1ex7ouffG4lT2ek9UdRRYkeO4opVMC+sKtgYkCUylZKYXajI\=) \ No newline at end of file diff --git a/config/uat/config.properties b/config/uat/config.properties index 31c8bc6..ca62273 100644 --- a/config/uat/config.properties +++ b/config/uat/config.properties @@ -1,2 +1,2 @@ -env.name=cube-dev-${env} +env.name=cube-dev secret.password=ENC(JiNmuGqZUIgmjnLq9I5ojk4BnSid5bKDh0pTzeLQJrnSjS8p9uhTcN8Y8vr5XcDR+XJzN7KYBezylEN2vssfGE8EF5EhnWvg25H8aEx3Nm0ABESgzEN5cGUFW2kLzYKA8oMMLYFGDai5GHf1YJg64M/HgTWX1fb533Y6XndhDvhZVtsSWOyqKppR/xTMh8pYia6tazjAZaK5KvPkoZGBNV6wNc608tg6D0IV3OrJh+hNiSETtL32Acilzgm0dwf+2xElfJqEc6DxYJeNJpTzFwxtxwA1FntdWd4KK58Uiosm0h1d7RLD7y3953leQPExZg8K5g+/NP3+lGVTqghKKVOyzU2HrMqPq5QLEsXog4MySj5qm7WMqcbhekKA7XV9iUTXtfOB34g0yz0Fb7BgobAWFnMI4nPeZjcjsRQam0nb4L/x00vRwcg6ltwM/YJ22HSrdgM8wxuJnUSK8QEmLSx9KUqr7JSA/VPRiSntqSjVIQAwxW7H/sFH5rJoJpI+CDDiHBQ7PlhEWXCPtb7FnN3oU+KSupFQUiQmsMQwgH0mI73JKk6KmBmyzwQmwjQ8PJ32g/W97vOpKMcEp9djXRXvOS9dzJd3vcsdec42ZfjNGDI6GOBancNKXACKlsanWS05dbaPl9BpUF0vKfY4kEJ+FHgmsKbRfkeYRZT2WjI\=) \ No newline at end of file diff --git a/create_table.sql b/create_table.sql new file mode 100644 index 0000000..23bae28 --- /dev/null +++ b/create_table.sql @@ -0,0 +1,19 @@ +drop table web_user; + +CREATE TABLE web_user ( + id int NOT NULL AUTO_INCREMENT, + login varchar(255) NOT NULL, + password varchar(255), + username varchar(255), + PRIMARY KEY (id) +); + + +create unique index login on `devop`.`web_user`(`login`); +-- create unique index `PRIMARY` on `devop`.`web_users`(`id`); + +insert into web_user (login,password,username) values ('user1','password','Chan Tai Man'); +insert into web_user (login,password,username) values ('user2','password','Wong Siu Ming'); + + +select * from web_user \ No newline at end of file diff --git a/pom.xml b/pom.xml index cb00a4f..b86ecc9 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,5 @@ - 4.0.0 @@ -48,6 +47,18 @@ jasypt-spring-boot 3.0.2 + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + mysql + mysql-connector-java + org.springframework.boot spring-boot-devtools diff --git a/src/main/java/com/cube/webDemo/controller/HelloController.java b/src/main/java/com/cube/webDemo/controller/HelloController.java index fc26c28..29d7cfa 100644 --- a/src/main/java/com/cube/webDemo/controller/HelloController.java +++ b/src/main/java/com/cube/webDemo/controller/HelloController.java @@ -1,15 +1,28 @@ package com.cube.webDemo.controller; import org.springframework.web.bind.annotation.RestController; + +import com.cube.webDemo.dao.WebUserDao; +import com.cube.webDemo.entity.WebUser; + +import java.util.Optional; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; +import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; @RestController public class HelloController { @Autowired Environment env; + + @Autowired + private WebUserDao webUserDao; + + @RequestMapping("/") public String index() { System.out.println("Request incoming"); @@ -19,4 +32,12 @@ public String index() { return "Hello Hello, current profile : " + env + ", config name : " + env.getProperty("env.name") + ", secret : " + env.getProperty("secret.password"); } + + @RequestMapping("/getWebUser") + public WebUser getWebUser(int id) { + WebUser u = webUserDao.findById(id).orElse(new WebUser()); + return u; + } + + } \ No newline at end of file diff --git a/src/main/java/com/cube/webDemo/controller/WebUserController.java b/src/main/java/com/cube/webDemo/controller/WebUserController.java new file mode 100644 index 0000000..c7eb17c --- /dev/null +++ b/src/main/java/com/cube/webDemo/controller/WebUserController.java @@ -0,0 +1,59 @@ +package com.cube.webDemo.controller; + +import java.util.ArrayList; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.context.request.WebRequest; + +import com.cube.webDemo.dao.WebUserDao; +import com.cube.webDemo.entity.WebUser; + +import antlr.collections.List; + +@Controller +public class WebUserController { + @Autowired + Environment env; + + @Autowired + private WebUserDao webUserDao; + + @GetMapping("/login") + public String showLoginPage(Model model) { + model.addAttribute("page_info", env.getProperty("env.name")); + //model.addAttribute("users", webUserDao.findAll()); + //model.addAttribute("error", "invalid losssgin"); + return "login"; + } + + @PostMapping("/login") + public String login(Model model, @RequestParam(value = "login") String login, @RequestParam(value = "password") String password) { + + ArrayList users = (ArrayList)webUserDao.findByLoginAndPassword(login, password); + + if(users.size()>0){ + return "redirect:getWebUserList"; + }else{ + model.addAttribute("error", "Invalid login"); + return showLoginPage(model); + } + + + } + + @RequestMapping("/getWebUserList") + public String greeting(@RequestParam(name="name", required=false, defaultValue="World") String name, Model model) { + //model.addAttribute("name", name); + model.addAttribute("users", webUserDao.findAll()); + + return "users"; + } +} diff --git a/src/main/java/com/cube/webDemo/dao/WebUserDao.java b/src/main/java/com/cube/webDemo/dao/WebUserDao.java new file mode 100644 index 0000000..9837093 --- /dev/null +++ b/src/main/java/com/cube/webDemo/dao/WebUserDao.java @@ -0,0 +1,15 @@ +package com.cube.webDemo.dao; + + +import java.util.List; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +import com.cube.webDemo.entity.WebUser; + + +@Repository +public interface WebUserDao extends CrudRepository{ + List findByLoginAndPassword(String login, String password); +} diff --git a/src/main/java/com/cube/webDemo/entity/WebUser.java b/src/main/java/com/cube/webDemo/entity/WebUser.java new file mode 100644 index 0000000..3a6df90 --- /dev/null +++ b/src/main/java/com/cube/webDemo/entity/WebUser.java @@ -0,0 +1,57 @@ +package com.cube.webDemo.entity; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "web_user") +public class WebUser { + @Id + @GeneratedValue + @Column(name = "id") + private int id; + + @Column(name = "login") + private String login; + + @Column(name = "password") + private String password; + + @Column(name = "username") + private String username; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getLogin() { + return login; + } + + public void setLogin(String login) { + this.login = login; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } +} diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 49b956a..98cad50 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -1,6 +1,16 @@ spring: - profiles: - active: '@spring.profiles.active@' + profiles: + active: '@spring.profiles.active@' + datasource: + url: jdbc:mysql://100.64.21.141:31907/devop + username: root + password: password + driver-class-name: com.mysql.cj.jdbc.Driver + jpa: + database-platform: org.hibernate.dialect.MySQL8Dialect + hibernate: + ddl-auto: update + server: port: 18080 env: @@ -65,4 +75,7 @@ jasypt: tTN4oPzywYB1AfxtlZ18C42UU1Cj1hAX4iYCM/sQL2klcitZ3almnEEFiM2gUXMo MSvTcHdAsQTZCM6TqTAOhuG24AwC -----END PRIVATE KEY----- - #privateKeyLocation: file:/var/app_certs/private.key \ No newline at end of file + #privateKeyLocation: file:/var/app_certs/private.key + + + \ No newline at end of file diff --git a/src/main/resources/templates/login.html b/src/main/resources/templates/login.html new file mode 100644 index 0000000..94e14cc --- /dev/null +++ b/src/main/resources/templates/login.html @@ -0,0 +1,21 @@ + + + + + + + ENV NAME : +
+
+
+ +
+
+
+
+
+
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/users.html b/src/main/resources/templates/users.html new file mode 100644 index 0000000..45c87e5 --- /dev/null +++ b/src/main/resources/templates/users.html @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + +
id login password username
No Data
+ \ No newline at end of file diff --git a/src/test/java/com/cube/webDemo/controller/WebUserControllerTest.java b/src/test/java/com/cube/webDemo/controller/WebUserControllerTest.java new file mode 100644 index 0000000..7986b47 --- /dev/null +++ b/src/test/java/com/cube/webDemo/controller/WebUserControllerTest.java @@ -0,0 +1,27 @@ +package com.cube.webDemo.controller; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + +import static org.hamcrest.Matchers.equalTo; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@SpringBootTest +@AutoConfigureMockMvc +public class WebUserControllerTest { + + @Autowired + private MockMvc mvc; + + @Test + public void getWebUserList() throws Exception { + mvc.perform(MockMvcRequestBuilders.get("/getWebUserList").accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()); + } +} \ No newline at end of file From 79f31e05b1041d3558ed59a067f0b7e885f98062 Mon Sep 17 00:00:00 2001 From: cubecc Date: Tue, 2 Jun 2020 17:38:16 +0800 Subject: [PATCH 039/121] dasd --- Jenkinsfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 33ad92b..1998c44 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -23,15 +23,15 @@ pipeline { stage('User Input') { steps { - timeout(60) { + timeout(1) { script { - approvalMap = input id: 'test', message: 'Hello', ok: 'Proceed?', parameters: [choice(choices: 'apple\npear\norange', description: 'Select a fruit for this build', name: 'FRUIT'), string(defaultValue: '', description: '', name: 'myparam')], submitter: 'user1,user2,group1', submitterParameter: 'APPROVER' + approvalMap = input id: 'test', message: 'Hello', ok: 'Proceed?', parameters: [choice(choices: 'dev\nuat\nprod', description: 'Select env to build', name: 'Environment'), string(defaultValue: '', description: '', name: 'Remarks')], submitter: 'user1,user2,group1', submitterParameter: 'APPROVER' } } echo "This build was approved by: ${approvalMap['APPROVER']}" - echo "This build is brought to you today by the fruit: ${approvalMap['FRUIT']}" - echo "This is myparam: ${approvalMap['myparam']}" + echo "build env: ${approvalMap['Environment']}" + echo "Remarks : ${approvalMap['Remarks']}" } } From 64e30db5f0c46cfcd2ec5af1803571937472afed Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 3 Jun 2020 10:00:43 +0800 Subject: [PATCH 040/121] dasd --- webdemo.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/webdemo.yaml b/webdemo.yaml index 9d953c2..db1698a 100644 --- a/webdemo.yaml +++ b/webdemo.yaml @@ -42,3 +42,17 @@ spec: port: 18080 nodePort: 31235 + +--- +apiVersion: autoscaling/v1 +kind: HorizontalPodAutoscaler +metadata: + name: webdemo-dev +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: webdemo-dev + minReplicas: 1 + maxReplicas: 10 + targetCPUUtilizationPercentage: 10 From 3b24b3e1851043e4312676edd140d39f0b46883b Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 3 Jun 2020 10:06:23 +0800 Subject: [PATCH 041/121] dasdasd --- webdemo.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/webdemo.yaml b/webdemo.yaml index db1698a..e4b82fa 100644 --- a/webdemo.yaml +++ b/webdemo.yaml @@ -5,7 +5,7 @@ kind: Deployment metadata: name: webdemo-dev spec: - replicas: 3 + replicas: 1 selector: matchLabels: app: webdemo-dev @@ -25,6 +25,11 @@ spec: - containerPort: 18080 name: webdemo-dev protocol: TCP + resources: + limits: + cpu: 200m + requests: + cpu: 100m imagePullSecrets: - name: regcred @@ -55,4 +60,4 @@ spec: name: webdemo-dev minReplicas: 1 maxReplicas: 10 - targetCPUUtilizationPercentage: 10 + targetCPUUtilizationPercentage: 20 From befe51d70cf0257df524eb389f731ae808a6ebdc Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 3 Jun 2020 10:15:36 +0800 Subject: [PATCH 042/121] dsad --- webdemo.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webdemo.yaml b/webdemo.yaml index e4b82fa..961a66f 100644 --- a/webdemo.yaml +++ b/webdemo.yaml @@ -27,9 +27,9 @@ spec: protocol: TCP resources: limits: - cpu: 200m + cpu: 500m requests: - cpu: 100m + cpu: 200m imagePullSecrets: - name: regcred @@ -60,4 +60,4 @@ spec: name: webdemo-dev minReplicas: 1 maxReplicas: 10 - targetCPUUtilizationPercentage: 20 + targetCPUUtilizationPercentage: 50 From c55d445941b70a06ded77b81e240b7ffe343cc93 Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 3 Jun 2020 10:35:48 +0800 Subject: [PATCH 043/121] dasdsad --- webdemo.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webdemo.yaml b/webdemo.yaml index 961a66f..213a409 100644 --- a/webdemo.yaml +++ b/webdemo.yaml @@ -27,9 +27,9 @@ spec: protocol: TCP resources: limits: - cpu: 500m + cpu: 1.5 requests: - cpu: 200m + cpu: 500m imagePullSecrets: - name: regcred From bbc02f3f522722010f2865c2740ad6fea94456c9 Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 3 Jun 2020 11:23:59 +0800 Subject: [PATCH 044/121] kkk --- webdemo.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webdemo.yaml b/webdemo.yaml index 213a409..b44be02 100644 --- a/webdemo.yaml +++ b/webdemo.yaml @@ -27,9 +27,9 @@ spec: protocol: TCP resources: limits: - cpu: 1.5 + cpu: 1 requests: - cpu: 500m + cpu: 250m imagePullSecrets: - name: regcred From 85b8b2d59695554b0464348f96aa4216ac645ea3 Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 3 Jun 2020 11:28:11 +0800 Subject: [PATCH 045/121] kkk --- webdemo.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webdemo.yaml b/webdemo.yaml index b44be02..213a409 100644 --- a/webdemo.yaml +++ b/webdemo.yaml @@ -27,9 +27,9 @@ spec: protocol: TCP resources: limits: - cpu: 1 + cpu: 1.5 requests: - cpu: 250m + cpu: 500m imagePullSecrets: - name: regcred From c3c60d9abe9a27674fb840e8f2745a84a3bc6461 Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 3 Jun 2020 12:12:19 +0800 Subject: [PATCH 046/121] testing --- src/main/resources/templates/login.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/templates/login.html b/src/main/resources/templates/login.html index 94e14cc..0e31e0d 100644 --- a/src/main/resources/templates/login.html +++ b/src/main/resources/templates/login.html @@ -5,7 +5,7 @@ - ENV NAME : + xxxxENV NAME :

From 0bf8235f3fee91b983dfac77527c8b371a4cf578 Mon Sep 17 00:00:00 2001 From: cubecc Date: Fri, 5 Jun 2020 16:25:28 +0800 Subject: [PATCH 047/121] dasd --- Jenkinsfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1998c44..e4a8f41 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -56,10 +56,13 @@ pipeline { } } - stage('QA') { + stage('SonarQube Analysis') { steps { - echo 'call sonar for qa (TODO)' + echo 'call sonar' //sh 'mvn sonar:sonar -Dsonar.login=$SONAR_PSW' + withSonarQubeEnv(){ + sh 'mvn sonar:sonar' + } } } From 9feebff4e9915f2278c51eba8311d318e0ac30c4 Mon Sep 17 00:00:00 2001 From: cubecc Date: Fri, 5 Jun 2020 16:29:20 +0800 Subject: [PATCH 048/121] dasdsad --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index e4a8f41..1b6279d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -60,7 +60,7 @@ pipeline { steps { echo 'call sonar' //sh 'mvn sonar:sonar -Dsonar.login=$SONAR_PSW' - withSonarQubeEnv(){ + withSonarQubeEnv('SonarQube'){ sh 'mvn sonar:sonar' } } From c83aa3cfafb92cd592b60d53b8f58b1335a55c31 Mon Sep 17 00:00:00 2001 From: cubecc Date: Fri, 5 Jun 2020 18:18:34 +0800 Subject: [PATCH 049/121] Test --- pom.xml | 8 +++++ .../webDemo/controller/WebUserController.java | 12 +++++-- src/main/resources/log4j2.xml | 35 +++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/log4j2.xml diff --git a/pom.xml b/pom.xml index b86ecc9..a6643d5 100644 --- a/pom.xml +++ b/pom.xml @@ -63,6 +63,14 @@ org.springframework.boot spring-boot-devtools + + org.springframework.boot + spring-boot-starter-log4j2 + + + org.projectlombok + lombok + org.springframework.boot spring-boot-starter-test diff --git a/src/main/java/com/cube/webDemo/controller/WebUserController.java b/src/main/java/com/cube/webDemo/controller/WebUserController.java index c7eb17c..f284260 100644 --- a/src/main/java/com/cube/webDemo/controller/WebUserController.java +++ b/src/main/java/com/cube/webDemo/controller/WebUserController.java @@ -1,7 +1,10 @@ package com.cube.webDemo.controller; import java.util.ArrayList; +import java.util.Date; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Controller; @@ -17,9 +20,12 @@ import com.cube.webDemo.entity.WebUser; import antlr.collections.List; +import lombok.extern.log4j.Log4j2; @Controller public class WebUserController { + private static final Logger logger = LogManager.getLogger(WebUserController.class); + @Autowired Environment env; @@ -28,6 +34,9 @@ public class WebUserController { @GetMapping("/login") public String showLoginPage(Model model) { + Date currentDate = new Date(); + logger.info("Test Log from k8 : Curent Date and Time - " + currentDate.toString()); + model.addAttribute("page_info", env.getProperty("env.name")); //model.addAttribute("users", webUserDao.findAll()); //model.addAttribute("error", "invalid losssgin"); @@ -45,8 +54,7 @@ public String login(Model model, @RequestParam(value = "login") String login, @R model.addAttribute("error", "Invalid login"); return showLoginPage(model); } - - + } @RequestMapping("/getWebUserList") diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml new file mode 100644 index 0000000..bfbef2d --- /dev/null +++ b/src/main/resources/log4j2.xml @@ -0,0 +1,35 @@ + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${hostName} --- [%15.15t] %-40.40c{1.} : %m%n%ex + + /var/log/webDemo + + + + + + + + + ${LOG_PATTERN} + + + + + + + + + + + + + + + + \ No newline at end of file From edb9aeeb12dae065e0afb09a3e08ba816a55dccd Mon Sep 17 00:00:00 2001 From: cubecc Date: Sat, 6 Jun 2020 11:27:09 +0800 Subject: [PATCH 050/121] test --- .myeclipse/profiler/WebDemoApplication.xml | 23 +++++++++++++++++++ pom.xml | 8 ++++++- .../com/cube/webDemo/WebDemoApplication.java | 2 +- src/main/resources/log4j2.xml | 4 ++-- 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 .myeclipse/profiler/WebDemoApplication.xml diff --git a/.myeclipse/profiler/WebDemoApplication.xml b/.myeclipse/profiler/WebDemoApplication.xml new file mode 100644 index 0000000..9145cd1 --- /dev/null +++ b/.myeclipse/profiler/WebDemoApplication.xml @@ -0,0 +1,23 @@ + + + +WebDemoApplication Launch Configuration + +com.cube.webDemo.* +10 + +1000 +false +com.cube.webDemo.** + +false +0 +false +100 +true + +1000 +true +true +false + diff --git a/pom.xml b/pom.xml index a6643d5..f31ae0d 100644 --- a/pom.xml +++ b/pom.xml @@ -41,6 +41,12 @@ org.springframework.boot spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-logging + + com.github.ulisesbocchio @@ -98,7 +104,7 @@ org.springframework.boot spring-boot-maven-plugin - + diff --git a/src/main/java/com/cube/webDemo/WebDemoApplication.java b/src/main/java/com/cube/webDemo/WebDemoApplication.java index e86aade..0c995ee 100644 --- a/src/main/java/com/cube/webDemo/WebDemoApplication.java +++ b/src/main/java/com/cube/webDemo/WebDemoApplication.java @@ -9,7 +9,7 @@ @EnableEncryptableProperties public class WebDemoApplication { - public static void main(String[] args) { + public static void main(String[] args) { SpringApplication.run(WebDemoApplication.class, args); } diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml index bfbef2d..6950f98 100644 --- a/src/main/resources/log4j2.xml +++ b/src/main/resources/log4j2.xml @@ -1,8 +1,8 @@ - + - %d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${hostName} --- [%15.15t] %-40.40c{1.} : %m%n%ex + %d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${hostName} --- [%15.15t] %-40.40c{1.} : %m%n%ex /var/log/webDemo From e87b07dded402ddbbe48a7f2849f21e42f2a23d2 Mon Sep 17 00:00:00 2001 From: cubecc Date: Sat, 6 Jun 2020 12:05:36 +0800 Subject: [PATCH 051/121] asdsd --- Dockerfile | 4 ++-- Jenkinsfile | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1f6add9..5742b25 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM openjdk:8-jdk-alpine -RUN addgroup -S webadmin && adduser -S webadmin -G webadmin -USER webadmin:webadmin +#RUN addgroup -S webadmin && adduser -S webadmin -G webadmin +#USER webadmin:webadmin ARG JAR_FILE=target/*.jar COPY ${JAR_FILE} app.jar EXPOSE 18080 diff --git a/Jenkinsfile b/Jenkinsfile index 1b6279d..e3f299f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -23,15 +23,16 @@ pipeline { stage('User Input') { steps { - timeout(1) { - script { - approvalMap = input id: 'test', message: 'Hello', ok: 'Proceed?', parameters: [choice(choices: 'dev\nuat\nprod', description: 'Select env to build', name: 'Environment'), string(defaultValue: '', description: '', name: 'Remarks')], submitter: 'user1,user2,group1', submitterParameter: 'APPROVER' - } - } - - echo "This build was approved by: ${approvalMap['APPROVER']}" - echo "build env: ${approvalMap['Environment']}" - echo "Remarks : ${approvalMap['Remarks']}" + echo 'wait user input...' +// timeout(1) { +// script { +// approvalMap = input id: 'test', message: 'Hello', ok: 'Proceed?', parameters: [choice(choices: 'dev\nuat\nprod', description: 'Select env to build', name: 'Environment'), string(defaultValue: '', description: '', name: 'Remarks')], submitter: 'user1,user2,group1', submitterParameter: 'APPROVER' +// } +// } +// +// echo "This build was approved by: ${approvalMap['APPROVER']}" +// echo "build env: ${approvalMap['Environment']}" +// echo "Remarks : ${approvalMap['Remarks']}" } } @@ -83,7 +84,7 @@ pipeline { stage('Deploy to K8') { steps{ - sh("kubectl replace -f webdemo.yaml --force") + sh("kubectl apply -f webdemo.yaml --force") } } From 65e1db78d856ad40349475d86824912ddb086953 Mon Sep 17 00:00:00 2001 From: cubecc Date: Sat, 6 Jun 2020 12:09:57 +0800 Subject: [PATCH 052/121] dasd --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index e3f299f..74ab9b4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -84,7 +84,7 @@ pipeline { stage('Deploy to K8') { steps{ - sh("kubectl apply -f webdemo.yaml --force") + sh("kubectl replace -f webdemo.yaml --force") } } From 985b17dbdd055ca029890ad14033f25ae167c81c Mon Sep 17 00:00:00 2001 From: cubecc Date: Sat, 6 Jun 2020 12:28:56 +0800 Subject: [PATCH 053/121] dasd --- webdemo.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/webdemo.yaml b/webdemo.yaml index 213a409..fd6813c 100644 --- a/webdemo.yaml +++ b/webdemo.yaml @@ -29,7 +29,15 @@ spec: limits: cpu: 1.5 requests: - cpu: 500m + cpu: 500m + volumeMounts: + - name: app-log-volume + mountPath: /var/log/webDemo/ + volumes: + - name: app-log-volume + hostPath: + # directory location on host + path: /var/log/k8s-mount/webDemo imagePullSecrets: - name: regcred From 61259615a4735b043582f45d450a53e38fcef149 Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 8 Jun 2020 18:02:00 +0800 Subject: [PATCH 054/121] dasd --- Jenkinsfile | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 74ab9b4..c2060a3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -45,7 +45,15 @@ pipeline { ''' } } - + + stage('Setup Env') { + steps { + script { + startZap(host: "100.64.21.108", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.*']) + } + } + } + stage('Build & Test') { steps { sh 'mvn clean package -P${env}' @@ -67,6 +75,19 @@ pipeline { } } + stage('OWASP Scan') { + steps { + sh 'mvn verify -Dhttp.proxyHost=100.64.21.108 -Dhttp.proxyPort=8088 -Dhttps.proxyHost=100.64.21.108 -Dhttps.proxyPort=8088' + } + post { + always { + script { + archiveZap(failAllAlerts: 1, failHighAlerts: 0, failMediumAlerts: 0, failLowAlerts: 0, falsePositivesFilePath: "zapFalsePositives.json") + } + } + } + } + stage('Build & Publish Images') { steps { From c494a3fb2b1ae0d3b729d80924492e2ee889911e Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 8 Jun 2020 18:07:13 +0800 Subject: [PATCH 055/121] dsad --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index c2060a3..0fdfc9b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -49,8 +49,9 @@ pipeline { stage('Setup Env') { steps { script { - startZap(host: "100.64.21.108", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.*']) + startZap(host: "100.64.21.108", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) } + sh "ps auxwww|grep -i zap" } } From b807d790e2dde0f2658f978049e5a39c1b0e78b6 Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 8 Jun 2020 18:34:20 +0800 Subject: [PATCH 056/121] dasdd --- Jenkinsfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0fdfc9b..7836d33 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -48,10 +48,11 @@ pipeline { stage('Setup Env') { steps { - script { - startZap(host: "100.64.21.108", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) - } - sh "ps auxwww|grep -i zap" + //script { + // startZap(host: "100.64.21.108", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) + //} + //sh "ps auxwww|grep -i zap" + echo '123' } } From 934719cf902c4546b03d2acba8d644d060b073a9 Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 8 Jun 2020 21:02:49 +0800 Subject: [PATCH 057/121] dsad --- Jenkinsfile | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7836d33..991869d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -47,12 +47,14 @@ pipeline { } stage('Setup Env') { + agent { label 'zap' } steps { - //script { - // startZap(host: "100.64.21.108", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) - //} - //sh "ps auxwww|grep -i zap" - echo '123' + script { + //startZap(host: "100.64.21.108", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) + startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) + } + sh "ps auxwww|grep -i zap" + //echo '123' } } @@ -79,7 +81,7 @@ pipeline { stage('OWASP Scan') { steps { - sh 'mvn verify -Dhttp.proxyHost=100.64.21.108 -Dhttp.proxyPort=8088 -Dhttps.proxyHost=100.64.21.108 -Dhttps.proxyPort=8088' + sh 'mvn verify -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8088 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=8088' } post { always { From e39451680e937ead6c0749a97f9a175f4f0b15a0 Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 8 Jun 2020 21:20:00 +0800 Subject: [PATCH 058/121] dasda --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 991869d..004a6b3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -50,8 +50,8 @@ pipeline { agent { label 'zap' } steps { script { - //startZap(host: "100.64.21.108", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) - startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) + startZap(host: "100.64.21.108", port: 8088, timeout:10000, zapHome: "/usr/share/owasp-zap", allowedHosts:['100.64.21.136']) + //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) } sh "ps auxwww|grep -i zap" //echo '123' From 4a6196e20be60cdd615335bc2dd789230460453c Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 8 Jun 2020 21:36:21 +0800 Subject: [PATCH 059/121] dasdsa --- Jenkinsfile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 004a6b3..60f1ffb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -50,10 +50,12 @@ pipeline { agent { label 'zap' } steps { script { - startZap(host: "100.64.21.108", port: 8088, timeout:10000, zapHome: "/usr/share/owasp-zap", allowedHosts:['100.64.21.136']) + //startZap(host: "100.64.21.108", port: 8088, timeout:10000, zapHome: "/usr/share/owasp-zap", allowedHosts:['100.64.21.136']) + startZap(host: "localhost", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap", allowedHosts:['100.64.21.136']) //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) + } - sh "ps auxwww|grep -i zap" + //sh "ps auxwww|grep -i zap" //echo '123' } } @@ -81,7 +83,11 @@ pipeline { stage('OWASP Scan') { steps { - sh 'mvn verify -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8088 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=8088' + //sh 'mvn verify -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8088 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=8088' + script { + runZapCrawler(host:"http://100.64.21.141:31235/") + runZapAttack() + } } post { always { From 890698002856ca71b66088c710a14aac64c272f2 Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 8 Jun 2020 21:38:29 +0800 Subject: [PATCH 060/121] ooo --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 60f1ffb..04cbe55 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -51,7 +51,7 @@ pipeline { steps { script { //startZap(host: "100.64.21.108", port: 8088, timeout:10000, zapHome: "/usr/share/owasp-zap", allowedHosts:['100.64.21.136']) - startZap(host: "localhost", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap", allowedHosts:['100.64.21.136']) + startZap(host: "127.0.0.1", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap", allowedHosts:['100.64.21.136']) //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) } From 86aa2a1130dbde6920b163267e6dd289a7be721d Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 8 Jun 2020 21:44:23 +0800 Subject: [PATCH 061/121] dasd --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 04cbe55..ba0f565 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -51,7 +51,7 @@ pipeline { steps { script { //startZap(host: "100.64.21.108", port: 8088, timeout:10000, zapHome: "/usr/share/owasp-zap", allowedHosts:['100.64.21.136']) - startZap(host: "127.0.0.1", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap", allowedHosts:['100.64.21.136']) + startZap(host: "100.64.21.108", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap", allowedHosts:['100.64.21.136']) //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) } From ab76e9d11ee5bca244bc1c8494650f9502b9d939 Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 8 Jun 2020 21:56:03 +0800 Subject: [PATCH 062/121] dasd --- Jenkinsfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ba0f565..717e39e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -51,7 +51,7 @@ pipeline { steps { script { //startZap(host: "100.64.21.108", port: 8088, timeout:10000, zapHome: "/usr/share/owasp-zap", allowedHosts:['100.64.21.136']) - startZap(host: "100.64.21.108", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap", allowedHosts:['100.64.21.136']) + startZap(host: "127.0.0.1", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) } @@ -75,13 +75,16 @@ pipeline { steps { echo 'call sonar' //sh 'mvn sonar:sonar -Dsonar.login=$SONAR_PSW' + /* withSonarQubeEnv('SonarQube'){ sh 'mvn sonar:sonar' - } + } + */ } } stage('OWASP Scan') { + agent { label 'zap' } steps { //sh 'mvn verify -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8088 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=8088' script { From 2d4eab04512f0e0971e3da9af485e306844b5eca Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 8 Jun 2020 22:14:24 +0800 Subject: [PATCH 063/121] dsd --- Jenkinsfile | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 717e39e..6e14166 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -45,21 +45,7 @@ pipeline { ''' } } - - stage('Setup Env') { - agent { label 'zap' } - steps { - script { - //startZap(host: "100.64.21.108", port: 8088, timeout:10000, zapHome: "/usr/share/owasp-zap", allowedHosts:['100.64.21.136']) - startZap(host: "127.0.0.1", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") - //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) - - } - //sh "ps auxwww|grep -i zap" - //echo '123' - } - } - + stage('Build & Test') { steps { sh 'mvn clean package -P${env}' @@ -88,19 +74,24 @@ pipeline { steps { //sh 'mvn verify -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8088 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=8088' script { + //startZap(host: "100.64.21.108", port: 8088, timeout:10000, zapHome: "/usr/share/owasp-zap", allowedHosts:['100.64.21.136']) + //startZap(host: "127.0.0.1", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") + //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) + sh '/usr/share/owasp-zap/zap.sh -daemon -host localhost -port 8088 -config api.disablekey=true -config api.addrs.addr.regex=true -config api.addrs.addr.name=.* -config connection.timeoutInSecs=600' + runZapCrawler(host:"http://100.64.21.141:31235/") - runZapAttack() + //runZapAttack() } } post { always { script { - archiveZap(failAllAlerts: 1, failHighAlerts: 0, failMediumAlerts: 0, failLowAlerts: 0, falsePositivesFilePath: "zapFalsePositives.json") + archiveZap(failAllAlerts: 100, failHighAlerts: 5, failMediumAlerts: 0, failLowAlerts: 0, falsePositivesFilePath: "zapFalsePositives.json") } } } } - + /* stage('Build & Publish Images') { steps { @@ -126,7 +117,9 @@ pipeline { steps{ echo 'ping' } - } + } + */ + //stage('Build and Publish Image') { //} From 0fd73120aec86e294b64eb524036b31099ab23a7 Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 8 Jun 2020 22:27:14 +0800 Subject: [PATCH 064/121] dasd --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6e14166..c8d5225 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -74,10 +74,10 @@ pipeline { steps { //sh 'mvn verify -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8088 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=8088' script { - //startZap(host: "100.64.21.108", port: 8088, timeout:10000, zapHome: "/usr/share/owasp-zap", allowedHosts:['100.64.21.136']) + startZap(host: "100.64.21.108", port: 8088, timeout:10000, zapHome: "/usr/share/owasp-zap") //startZap(host: "127.0.0.1", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) - sh '/usr/share/owasp-zap/zap.sh -daemon -host localhost -port 8088 -config api.disablekey=true -config api.addrs.addr.regex=true -config api.addrs.addr.name=.* -config connection.timeoutInSecs=600' + runZapCrawler(host:"http://100.64.21.141:31235/") //runZapAttack() From 233f67b51cf41976286c33005a66831b368d16c1 Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 8 Jun 2020 22:28:30 +0800 Subject: [PATCH 065/121] dasd --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index c8d5225..58e9137 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -48,7 +48,7 @@ pipeline { stage('Build & Test') { steps { - sh 'mvn clean package -P${env}' + sh 'mvn clean package -P${env} -DskipTests' } post { success { From acae847766ca056962e6a76a8f0f4d3f2831498a Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 8 Jun 2020 22:29:36 +0800 Subject: [PATCH 066/121] dasd --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 58e9137..0cf6210 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -52,7 +52,7 @@ pipeline { } post { success { - junit 'target/surefire-reports/**/*.xml' + //junit 'target/surefire-reports/**/*.xml' } } } From b0888b12a5301c55cc87bcd7fb9eb388b6714851 Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 8 Jun 2020 22:30:26 +0800 Subject: [PATCH 067/121] dasdasd --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 0cf6210..2c7840b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -52,6 +52,7 @@ pipeline { } post { success { + echo 'generate test report' //junit 'target/surefire-reports/**/*.xml' } } From a1d0ee80ea945e4fe290592c862fd2c760dd5b09 Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 8 Jun 2020 22:38:30 +0800 Subject: [PATCH 068/121] dasd --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2c7840b..3aa5e69 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -75,13 +75,13 @@ pipeline { steps { //sh 'mvn verify -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8088 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=8088' script { - startZap(host: "100.64.21.108", port: 8088, timeout:10000, zapHome: "/usr/share/owasp-zap") + startZap(host: "100.64.21.108", port: 8088, timeout:10000, zapHome: "/usr/share/owasp-zap", sessionPath:"/var/lib/jenkins/session.session") //startZap(host: "127.0.0.1", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) - runZapCrawler(host:"http://100.64.21.141:31235/") - //runZapAttack() + //runZapCrawler(host:"http://100.64.21.141:31235/") + runZapAttack() } } post { From bb85cd9abebc402bd74e22579acc94ed53d8ebfb Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 8 Jun 2020 22:41:20 +0800 Subject: [PATCH 069/121] dasd --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3aa5e69..0ce6f9e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -75,7 +75,7 @@ pipeline { steps { //sh 'mvn verify -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8088 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=8088' script { - startZap(host: "100.64.21.108", port: 8088, timeout:10000, zapHome: "/usr/share/owasp-zap", sessionPath:"/var/lib/jenkins/session.session") + startZap(host: "100.64.21.108", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") //startZap(host: "127.0.0.1", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) From 741c901a8a05b7fe09ef10d163e46cc895f3a5e0 Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 8 Jun 2020 22:44:06 +0800 Subject: [PATCH 070/121] sda --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0ce6f9e..3bc5eba 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -75,7 +75,7 @@ pipeline { steps { //sh 'mvn verify -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8088 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=8088' script { - startZap(host: "100.64.21.108", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") + startZap(host: "100.64.21.108", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap",allowedHosts:['www.yahoo.com.hk']) //startZap(host: "127.0.0.1", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) From 0a3e64b8bb55655769f1f5fc46dd3267773d19ac Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 8 Jun 2020 22:51:47 +0800 Subject: [PATCH 071/121] dasd --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3bc5eba..5a95273 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -75,7 +75,7 @@ pipeline { steps { //sh 'mvn verify -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8088 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=8088' script { - startZap(host: "100.64.21.108", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap",allowedHosts:['www.yahoo.com.hk']) + startZap(host: "100.64.21.108", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap",allowedHosts:['100.64.21.141']) //startZap(host: "127.0.0.1", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) From bc69c9f576dfe65b7aa51f9436ef8db38015c5cb Mon Sep 17 00:00:00 2001 From: cubecc Date: Mon, 8 Jun 2020 22:54:32 +0800 Subject: [PATCH 072/121] dsad --- Jenkinsfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5a95273..93017bf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -75,13 +75,14 @@ pipeline { steps { //sh 'mvn verify -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8088 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=8088' script { - startZap(host: "100.64.21.108", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap",allowedHosts:['100.64.21.141']) + startZap(host: "100.64.21.108", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") //startZap(host: "127.0.0.1", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) //runZapCrawler(host:"http://100.64.21.141:31235/") - runZapAttack() + runZapCrawler(host:"http://www.yahoo.com.hk/") + //runZapAttack() } } post { From 69baf6852ab3e0ab6a16e2a20a9f5b48c8a96a7f Mon Sep 17 00:00:00 2001 From: cubecc Date: Tue, 9 Jun 2020 00:28:12 +0800 Subject: [PATCH 073/121] dasd --- Jenkinsfile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 93017bf..2453beb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -78,11 +78,9 @@ pipeline { startZap(host: "100.64.21.108", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") //startZap(host: "127.0.0.1", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) - - - //runZapCrawler(host:"http://100.64.21.141:31235/") - runZapCrawler(host:"http://www.yahoo.com.hk/") - //runZapAttack() + sh "mvn verify -Dhttp.proxyHost=100.64.21.108 -Dhttp.proxyPort=8088 -Dhttps.proxyHost=100.64.21.108 -Dhttps.proxyPort=8088 -DskipTests" + runZapCrawler(host:"http://localhost:18080") + runZapAttack() } } post { From 161e6bafe8030062e94766475c304fc32eb22017 Mon Sep 17 00:00:00 2001 From: cubecc Date: Tue, 9 Jun 2020 00:56:50 +0800 Subject: [PATCH 074/121] dad --- Jenkinsfile | 2 +- pom.xml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2453beb..97ae0de 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -78,7 +78,7 @@ pipeline { startZap(host: "100.64.21.108", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") //startZap(host: "127.0.0.1", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) - sh "mvn verify -Dhttp.proxyHost=100.64.21.108 -Dhttp.proxyPort=8088 -Dhttps.proxyHost=100.64.21.108 -Dhttps.proxyPort=8088 -DskipTests" + sh "mvn verify -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dhttp.proxyHost=100.64.21.108 -Dhttp.proxyPort=8088 -Dhttps.proxyHost=100.64.21.108 -Dhttps.proxyPort=8088 -DskipTests" runZapCrawler(host:"http://localhost:18080") runZapAttack() } diff --git a/pom.xml b/pom.xml index f31ae0d..1ee93ff 100644 --- a/pom.xml +++ b/pom.xml @@ -15,8 +15,7 @@ Demo - 1.8 - + 1.8 From 96584d54670708d4e4faf95cc694f8a49b47c330 Mon Sep 17 00:00:00 2001 From: cubecc Date: Tue, 9 Jun 2020 01:07:08 +0800 Subject: [PATCH 075/121] dasd --- Jenkinsfile | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 97ae0de..7bc3919 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -70,15 +70,24 @@ pipeline { } } - stage('OWASP Scan') { + stage('xxx Analysis') { agent { label 'zap' } + steps { + script { + startZap(host: "100.64.21.108", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") + } + } + } + + stage('OWASP Scan') { + //agent { label 'zap' } steps { //sh 'mvn verify -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8088 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=8088' script { - startZap(host: "100.64.21.108", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") + //startZap(host: "100.64.21.108", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") //startZap(host: "127.0.0.1", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) - sh "mvn verify -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dhttp.proxyHost=100.64.21.108 -Dhttp.proxyPort=8088 -Dhttps.proxyHost=100.64.21.108 -Dhttps.proxyPort=8088 -DskipTests" + //sh "mvn verify -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dhttp.proxyHost=100.64.21.108 -Dhttp.proxyPort=8088 -Dhttps.proxyHost=100.64.21.108 -Dhttps.proxyPort=8088 -DskipTests" runZapCrawler(host:"http://localhost:18080") runZapAttack() } From b76df4389b128fe0c796c8b9762d7bcc40fd974c Mon Sep 17 00:00:00 2001 From: cubecc Date: Tue, 9 Jun 2020 01:17:20 +0800 Subject: [PATCH 076/121] dsd --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7bc3919..599c1d1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -87,7 +87,7 @@ pipeline { //startZap(host: "100.64.21.108", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") //startZap(host: "127.0.0.1", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) - //sh "mvn verify -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dhttp.proxyHost=100.64.21.108 -Dhttp.proxyPort=8088 -Dhttps.proxyHost=100.64.21.108 -Dhttps.proxyPort=8088 -DskipTests" + sh "mvn verify -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dhttp.proxyHost=100.64.21.108 -Dhttp.proxyPort=8088 -Dhttps.proxyHost=100.64.21.108 -Dhttps.proxyPort=8088 -DskipTests" runZapCrawler(host:"http://localhost:18080") runZapAttack() } From e3bf7c86f585a5f39663c49c58d8c9b6427c5523 Mon Sep 17 00:00:00 2001 From: cubecc Date: Tue, 9 Jun 2020 01:40:00 +0800 Subject: [PATCH 077/121] dasd --- Jenkinsfile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 599c1d1..720452d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -69,7 +69,7 @@ pipeline { */ } } - + /* stage('xxx Analysis') { agent { label 'zap' } steps { @@ -78,7 +78,7 @@ pipeline { } } } - + */ stage('OWASP Scan') { //agent { label 'zap' } steps { @@ -87,9 +87,10 @@ pipeline { //startZap(host: "100.64.21.108", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") //startZap(host: "127.0.0.1", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) - sh "mvn verify -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dhttp.proxyHost=100.64.21.108 -Dhttp.proxyPort=8088 -Dhttps.proxyHost=100.64.21.108 -Dhttps.proxyPort=8088 -DskipTests" - runZapCrawler(host:"http://localhost:18080") - runZapAttack() + sh "mvn verify -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dhttp.proxyHost=100.64.21.108 -Dhttp.proxyPort=8088 -Dhttps.proxyHost=100.64.21.108 -Dhttps.proxyPort=8088 -DskipTests" + sh "curl http://localhost:18080" + //runZapCrawler(host:"http://localhost:18080") + //runZapAttack() } } post { From added9f383a25b329a82981641bb4249fe1d974f Mon Sep 17 00:00:00 2001 From: cubecc Date: Tue, 9 Jun 2020 10:01:14 +0800 Subject: [PATCH 078/121] dsad --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 720452d..0c6b907 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -87,7 +87,8 @@ pipeline { //startZap(host: "100.64.21.108", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") //startZap(host: "127.0.0.1", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) - sh "mvn verify -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dhttp.proxyHost=100.64.21.108 -Dhttp.proxyPort=8088 -Dhttps.proxyHost=100.64.21.108 -Dhttps.proxyPort=8088 -DskipTests" + //sh "mvn verify -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dhttp.proxyHost=100.64.21.108 -Dhttp.proxyPort=8088 -Dhttps.proxyHost=100.64.21.108 -Dhttps.proxyPort=8088 -DskipTests" + sh "mvn spring-boot:run" sh "curl http://localhost:18080" //runZapCrawler(host:"http://localhost:18080") //runZapAttack() From 36ed319827088b66308eed1421ee15b107238e5c Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 10:09:49 +0800 Subject: [PATCH 079/121] dsadd --- Jenkinsfile | 91 ++++++++++++++++++++++++----------------------------- 1 file changed, 41 insertions(+), 50 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0c6b907..0037c2e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ pipeline { agent any environment { - registry = "registry.lab.local:5000/webdemo-dev" + //registry = "registry.lab.local:5000/webdemo-dev" //registryUrl = 'https://100.64.21.108:5000' registryUrl = 'https://registry.lab.local:5000' //registryCredential = 'docker-registry-100.64.21.108' @@ -48,12 +48,13 @@ pipeline { stage('Build & Test') { steps { - sh 'mvn clean package -P${env} -DskipTests' + //sh 'mvn clean package -P${env} -DskipTests' + sh 'mvn clean package -P${env}' } post { success { - echo 'generate test report' - //junit 'target/surefire-reports/**/*.xml' + //echo 'generate test report' + junit 'target/surefire-reports/**/*.xml' } } } @@ -62,47 +63,15 @@ pipeline { steps { echo 'call sonar' //sh 'mvn sonar:sonar -Dsonar.login=$SONAR_PSW' - /* + withSonarQubeEnv('SonarQube'){ sh 'mvn sonar:sonar' } - */ + } } - /* - stage('xxx Analysis') { - agent { label 'zap' } - steps { - script { - startZap(host: "100.64.21.108", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") - } - } - } - */ - stage('OWASP Scan') { - //agent { label 'zap' } - steps { - //sh 'mvn verify -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8088 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=8088' - script { - //startZap(host: "100.64.21.108", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") - //startZap(host: "127.0.0.1", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") - //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) - //sh "mvn verify -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dhttp.proxyHost=100.64.21.108 -Dhttp.proxyPort=8088 -Dhttps.proxyHost=100.64.21.108 -Dhttps.proxyPort=8088 -DskipTests" - sh "mvn spring-boot:run" - sh "curl http://localhost:18080" - //runZapCrawler(host:"http://localhost:18080") - //runZapAttack() - } - } - post { - always { - script { - archiveZap(failAllAlerts: 100, failHighAlerts: 5, failMediumAlerts: 0, failLowAlerts: 0, falsePositivesFilePath: "zapFalsePositives.json") - } - } - } - } - /* + + stage('Build & Publish Images') { steps { @@ -111,7 +80,8 @@ pipeline { sh ''' docker build -t ${IMAGE}:${VERSION} . docker tag ${IMAGE}:${VERSION} ${IMAGE}:latest - docker push ${IMAGE}:latest + docker push ${IMAGE}:${VERSION} + docker push ${IMAGE}:latest ''' } } @@ -122,14 +92,7 @@ pipeline { steps{ sh("kubectl replace -f webdemo.yaml --force") } - } - - stage('Post test') { - steps{ - echo 'ping' - } - } - */ + } //stage('Build and Publish Image') { //} @@ -138,7 +101,35 @@ pipeline { // steps{ // deleteDir() // } - //} + //} + + stage('OWASP Scan') { + agent { label 'zap' } + steps { + //sh 'mvn verify -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8088 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=8088' + script { + startZap(host: "100.64.21.108", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") + //startZap(host: "127.0.0.1", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") + //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) + sh "mvn verify -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dhttp.proxyHost=100.64.21.108 -Dhttp.proxyPort=8088 -Dhttps.proxyHost=100.64.21.108 -Dhttps.proxyPort=8088 -DskipTests" + runZapCrawler(host:"http://100.64.21.141:31235") + //runZapAttack() + } + } + post { + always { + script { + archiveZap(failAllAlerts: 100, failHighAlerts: 5, failMediumAlerts: 0, failLowAlerts: 0, falsePositivesFilePath: "zapFalsePositives.json") + } + } + } + } + + stage('Post test') { + steps{ + echo 'ping curl...' + } + } } post { From d98e70e14998ed7cae17ef26adb25b3886a52099 Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 10:17:29 +0800 Subject: [PATCH 080/121] dasdad --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0037c2e..caba22d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -111,7 +111,7 @@ pipeline { startZap(host: "100.64.21.108", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") //startZap(host: "127.0.0.1", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) - sh "mvn verify -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dhttp.proxyHost=100.64.21.108 -Dhttp.proxyPort=8088 -Dhttps.proxyHost=100.64.21.108 -Dhttps.proxyPort=8088 -DskipTests" + //sh "mvn verify -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dhttp.proxyHost=100.64.21.108 -Dhttp.proxyPort=8088 -Dhttps.proxyHost=100.64.21.108 -Dhttps.proxyPort=8088 -DskipTests" runZapCrawler(host:"http://100.64.21.141:31235") //runZapAttack() } From cfd68ca1e1d2ebdf8519584c99c1f6a0b44589f2 Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 10:25:45 +0800 Subject: [PATCH 081/121] dasds --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index caba22d..5b657b5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -113,7 +113,7 @@ pipeline { //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) //sh "mvn verify -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dhttp.proxyHost=100.64.21.108 -Dhttp.proxyPort=8088 -Dhttps.proxyHost=100.64.21.108 -Dhttps.proxyPort=8088 -DskipTests" runZapCrawler(host:"http://100.64.21.141:31235") - //runZapAttack() + runZapAttack() } } post { From e1123a8134c2d407a5300dbe8bbb8cc4a17ee7af Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 10:31:15 +0800 Subject: [PATCH 082/121] dasd --- Jenkinsfile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5b657b5..a650ac8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -67,11 +67,19 @@ pipeline { withSonarQubeEnv('SonarQube'){ sh 'mvn sonar:sonar' } - - } + } } - + stage('Quality Gate'){ + timeout(time: 1, unit: 'HOURS') { + def qg = waitForQualityGate() + //if (qg.status != 'OK') { + // error "Pipeline aborted due to quality gate failure: ${qg.status}" + //} + echo "Quality gate status: ${qg.status}" + } + } + stage('Build & Publish Images') { steps { From 3a52d42cffd0e04808ebab41595c85dd8a3fe00b Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 10:33:50 +0800 Subject: [PATCH 083/121] dasdasd --- Jenkinsfile | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a650ac8..00de23b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -71,12 +71,14 @@ pipeline { } stage('Quality Gate'){ - timeout(time: 1, unit: 'HOURS') { - def qg = waitForQualityGate() - //if (qg.status != 'OK') { - // error "Pipeline aborted due to quality gate failure: ${qg.status}" - //} - echo "Quality gate status: ${qg.status}" + steps { + timeout(time: 1, unit: 'HOURS') { + def qg = waitForQualityGate() + //if (qg.status != 'OK') { + // error "Pipeline aborted due to quality gate failure: ${qg.status}" + //} + echo "Quality gate status: ${qg.status}" + } } } From 628ea40eaf344eb3189ea649c69553d693a13578 Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 10:41:47 +0800 Subject: [PATCH 084/121] fyjfj --- Jenkinsfile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 00de23b..658d5ec 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -69,7 +69,15 @@ pipeline { } } } - + + stage("Quality Gate") { + steps { + timeout(time: 1, unit: 'HOURS') { + waitForQualityGate abortPipeline: true + } + } + } + /* stage('Quality Gate'){ steps { timeout(time: 1, unit: 'HOURS') { @@ -81,7 +89,7 @@ pipeline { } } } - + */ stage('Build & Publish Images') { steps { From 887a981d3fe4d7770fd542ef31a5c7b8d2a872f8 Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 12:21:08 +0800 Subject: [PATCH 085/121] dasdsad --- Jenkinsfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 658d5ec..1b9ce0d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,7 +11,8 @@ pipeline { env= "dev" //IMAGE = readMavenPom().getArtifactId() //VERSION = readMavenPom().getVersion() - IMAGE = "registry.lab.local:5000/webdemo-dev" + appname = "webdemo-dev" + IMAGE = "registry.lab.local:5000/${appname}" VERSION = "${BUILD_NUMBER}" } @@ -108,7 +109,10 @@ pipeline { stage('Deploy to K8') { steps{ - sh("kubectl replace -f webdemo.yaml --force") + sh ''' + kubectl replace -f webdemo.yaml --force + kubectl rollout status deployment ${appname} --watch --timeout=5m + ''' } } From f3acdb6be87e7081c2775bf7fb1b4ba047d6e48e Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 12:33:34 +0800 Subject: [PATCH 086/121] dasdad --- Jenkinsfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1b9ce0d..45b8707 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -126,7 +126,7 @@ pipeline { //} stage('OWASP Scan') { - agent { label 'zap' } + agent { label 'zap' options { skipDefaultCheckout() } } steps { //sh 'mvn verify -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8088 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=8088' script { @@ -134,8 +134,9 @@ pipeline { //startZap(host: "127.0.0.1", port: 8088, timeout:500, zapHome: "/usr/share/owasp-zap") //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) //sh "mvn verify -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dhttp.proxyHost=100.64.21.108 -Dhttp.proxyPort=8088 -Dhttps.proxyHost=100.64.21.108 -Dhttps.proxyPort=8088 -DskipTests" - runZapCrawler(host:"http://100.64.21.141:31235") - runZapAttack() + runZapCrawler(host:"http://100.64.21.141:31235") + runZapCrawler(host:"http://100.64.21.141:31235/getWebUserList") + //runZapAttack() } } post { From 5d710a57384f84f5c6edda90d21e8b0cbb7faf5c Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 12:44:00 +0800 Subject: [PATCH 087/121] dasds --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 45b8707..6101734 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -126,7 +126,8 @@ pipeline { //} stage('OWASP Scan') { - agent { label 'zap' options { skipDefaultCheckout() } } + agent { label 'zap' } + options { skipDefaultCheckout() } steps { //sh 'mvn verify -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8088 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=8088' script { From 53dcad6e6a44ede3f03551d7090af6354c2c950e Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 14:18:48 +0800 Subject: [PATCH 088/121] dasdsa --- Jenkinsfile | 2 +- src/main/resources/templates/login.html | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6101734..44e27b7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -136,7 +136,7 @@ pipeline { //startZap(host: "localhost", port: 8088, timeout:1000, zapHome: "/usr/share/owasp-zap", sessionPath:"/tmp/session.session", allowedHosts:['100.64.21.136']) //sh "mvn verify -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dhttp.proxyHost=100.64.21.108 -Dhttp.proxyPort=8088 -Dhttps.proxyHost=100.64.21.108 -Dhttps.proxyPort=8088 -DskipTests" runZapCrawler(host:"http://100.64.21.141:31235") - runZapCrawler(host:"http://100.64.21.141:31235/getWebUserList") + //runZapCrawler(host:"http://100.64.21.141:31235/getWebUserList") //runZapAttack() } } diff --git a/src/main/resources/templates/login.html b/src/main/resources/templates/login.html index 0e31e0d..61491c2 100644 --- a/src/main/resources/templates/login.html +++ b/src/main/resources/templates/login.html @@ -17,5 +17,6 @@
+ web user list \ No newline at end of file From 830016b2f9b8d96651690ca43a815890508dc64a Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 16:02:00 +0800 Subject: [PATCH 089/121] dasdasd --- Jenkinsfile | 75 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 27 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 44e27b7..3a6b1f1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,7 +21,7 @@ pipeline { } stages { - + /* stage('User Input') { steps { echo 'wait user input...' @@ -55,7 +55,7 @@ pipeline { post { success { //echo 'generate test report' - junit 'target/surefire-reports/**/*.xml' + junit 'target/surefire-reports//*.xml' } } } @@ -71,40 +71,48 @@ pipeline { } } - stage("Quality Gate") { + stage("Quality Gate") { steps { timeout(time: 1, unit: 'HOURS') { waitForQualityGate abortPipeline: true } } - } - /* - stage('Quality Gate'){ - steps { - timeout(time: 1, unit: 'HOURS') { - def qg = waitForQualityGate() - //if (qg.status != 'OK') { - // error "Pipeline aborted due to quality gate failure: ${qg.status}" - //} - echo "Quality gate status: ${qg.status}" - } - } - } - */ - stage('Build & Publish Images') { + } + + stage('Build Docker Images') { - steps { - script { - docker.withRegistry( registryUrl, registryCredential ) { + steps { + script { + docker.withRegistry( registryUrl, registryCredential ) { + sh ''' + docker build -t ${IMAGE}:${VERSION} . + ''' + } + } + } + } + + stage('Docker security analysis'){ + steps { + echo 'Performing Docker image analysis' + //sh "CLAIR_ADDR=localhost:6060 CLAIR_OUTPUT=High CLAIR_THRESHOLD=100 /home/yyy/ ${IMAGE}:${VERSION}" + } + } + + + stage('Push Docker Images') { + + steps { + script { + docker.withRegistry( registryUrl, registryCredential ) { sh ''' - docker build -t ${IMAGE}:${VERSION} . docker tag ${IMAGE}:${VERSION} ${IMAGE}:latest docker push ${IMAGE}:${VERSION} docker push ${IMAGE}:latest ''' - } - } - } + } + } + } } stage('Deploy to K8') { @@ -114,8 +122,8 @@ pipeline { kubectl rollout status deployment ${appname} --watch --timeout=5m ''' } - } - + } + //stage('Build and Publish Image') { //} @@ -148,6 +156,19 @@ pipeline { } } } + */ + + stage('OWASP Scan') { + steps { + runLog = sh ( + script: "docker run -v ${workspace}:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html", + returnStatus: true + ) == 0 + echo "ZAP Run Log: ${runLog}" + } + } + + stage('Post test') { steps{ From c98c8e042c6043df0732b8b298db08d2f9489003 Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 16:07:19 +0800 Subject: [PATCH 090/121] dsadasd --- Jenkinsfile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3a6b1f1..a50289c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -160,10 +160,7 @@ pipeline { stage('OWASP Scan') { steps { - runLog = sh ( - script: "docker run -v ${workspace}:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html", - returnStatus: true - ) == 0 + runLog = sh (script: "docker run -v ${workspace}:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html", returnStatus: true) echo "ZAP Run Log: ${runLog}" } } From 9c16975e5188dfc861df3300994fa019c009abec Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 16:10:38 +0800 Subject: [PATCH 091/121] dasds --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index a50289c..9f94e77 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -160,7 +160,7 @@ pipeline { stage('OWASP Scan') { steps { - runLog = sh (script: "docker run -v ${workspace}:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html", returnStatus: true) + runLog = sh (script: "docker run -v ${workspace}:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html", returnStatus: true).trim() echo "ZAP Run Log: ${runLog}" } } From c600b51f800e8def666cd1714d3910c2c4d21671 Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 16:12:33 +0800 Subject: [PATCH 092/121] dasdasd --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9f94e77..9551a94 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -160,7 +160,7 @@ pipeline { stage('OWASP Scan') { steps { - runLog = sh (script: "docker run -v ${workspace}:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html", returnStatus: true).trim() + runLog = sh (script: "docker run -v /tmp:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html", returnStatus: true).trim() echo "ZAP Run Log: ${runLog}" } } From fdc89212b65fbcba7189dd3661e76fd198706d22 Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 16:15:57 +0800 Subject: [PATCH 093/121] dadasd --- Jenkinsfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9551a94..0f8381c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -160,8 +160,10 @@ pipeline { stage('OWASP Scan') { steps { - runLog = sh (script: "docker run -v /tmp:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html", returnStatus: true).trim() - echo "ZAP Run Log: ${runLog}" + script { + runLog = sh (script: "docker run -v /tmp:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html", returnStatus: true).trim() + echo "ZAP Run Log: ${runLog}" + } } } From 145373ac6c16732ed016c0f7f787dc14bb0c03f1 Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 16:41:15 +0800 Subject: [PATCH 094/121] lll --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0f8381c..fe2fdab 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -161,7 +161,7 @@ pipeline { stage('OWASP Scan') { steps { script { - runLog = sh (script: "docker run -v /tmp:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html", returnStatus: true).trim() + runLog = sh (script: "docker run -v ${workspace}:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html", returnStatus: true) echo "ZAP Run Log: ${runLog}" } } From 25994bbe524c6939371c4246b1f56b6b681ce46f Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 16:44:43 +0800 Subject: [PATCH 095/121] ''' --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index fe2fdab..1818ed2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -179,7 +179,7 @@ pipeline { post { always { echo 'post status : clearup workspace' - deleteDir() /* clean up our workspace */ + //deleteDir() /* clean up our workspace */ } success { echo 'post status : success' From 3a8ac226e4b0b77b74d53f29ff447ecf2319e8f0 Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 16:59:41 +0800 Subject: [PATCH 096/121] dsadsad --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1818ed2..ad21c69 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -161,7 +161,7 @@ pipeline { stage('OWASP Scan') { steps { script { - runLog = sh (script: "docker run -v ${workspace}:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html", returnStatus: true) + runLog = sh (script: "docker run --user ${(id -u)}:${(id -g)} -v ${workspace}:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html", returnStatus: true) echo "ZAP Run Log: ${runLog}" } } From fd06fd05e9c79c5cc00d8acd848d49bb792d7888 Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 17:01:10 +0800 Subject: [PATCH 097/121] dsad --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index ad21c69..f91072c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -161,7 +161,7 @@ pipeline { stage('OWASP Scan') { steps { script { - runLog = sh (script: "docker run --user ${(id -u)}:${(id -g)} -v ${workspace}:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html", returnStatus: true) + runLog = sh (script: "docker run --user ${id -u}:${id -g} -v ${workspace}:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html", returnStatus: true) echo "ZAP Run Log: ${runLog}" } } From 5812a1ff243b72d8303b1f5d5bb38fc6ebb93d5b Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 17:02:29 +0800 Subject: [PATCH 098/121] dsad --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f91072c..ce60f0b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -161,7 +161,7 @@ pipeline { stage('OWASP Scan') { steps { script { - runLog = sh (script: "docker run --user ${id -u}:${id -g} -v ${workspace}:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html", returnStatus: true) + runLog = sh (script: "docker run --user $(id -u):$(id -g) -v ${workspace}:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html", returnStatus: true) echo "ZAP Run Log: ${runLog}" } } From ae171d0c6552210362332442e0f562c1d45074d4 Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 17:04:02 +0800 Subject: [PATCH 099/121] dsad --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index ce60f0b..2e55177 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -161,7 +161,8 @@ pipeline { stage('OWASP Scan') { steps { script { - runLog = sh (script: "docker run --user $(id -u):$(id -g) -v ${workspace}:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html", returnStatus: true) + sh "whoami" + runLog = sh (script: "docker run --user \$(id -u):\$(id -g) -v ${workspace}:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html", returnStatus: true) echo "ZAP Run Log: ${runLog}" } } From 1679a649f8b64e5436da30b50afc05d753098931 Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 17:15:16 +0800 Subject: [PATCH 100/121] dsadsa --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2e55177..5d5ee6e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -160,11 +160,11 @@ pipeline { stage('OWASP Scan') { steps { - script { - sh "whoami" + script { runLog = sh (script: "docker run --user \$(id -u):\$(id -g) -v ${workspace}:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html", returnStatus: true) echo "ZAP Run Log: ${runLog}" - } + publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: './', reportFiles: 'zap_report.html', reportName: 'ZAP Scan', reportTitles: 'ZAP Scan']) + } } } From 690e1af668e414c2fd502e0ae00dab4d6ed63692 Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 17:16:26 +0800 Subject: [PATCH 101/121] dasd --- Jenkinsfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5d5ee6e..81c59cb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -168,8 +168,6 @@ pipeline { } } - - stage('Post test') { steps{ echo 'ping curl...' From 10189d614c3d1778ae4111b08782be9c865bccc0 Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 17:39:35 +0800 Subject: [PATCH 102/121] dasds --- Jenkinsfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 81c59cb..c9e068d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -161,9 +161,10 @@ pipeline { stage('OWASP Scan') { steps { script { - runLog = sh (script: "docker run --user \$(id -u):\$(id -g) -v ${workspace}:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html", returnStatus: true) - echo "ZAP Run Log: ${runLog}" - publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: './', reportFiles: 'zap_report.html', reportName: 'ZAP Scan', reportTitles: 'ZAP Scan']) + //runLog = sh (script: "docker run --user \$(id -u):\$(id -g) -v ${workspace}:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html", returnStatus: true) + runLog = sh (script: "docker run --user \$(id -u):\$(id -g) -v ${workspace}:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://www.yahoo.com.hk -r zap_report.html", returnStatus: true) + //echo "ZAP Run Log: ${runLog}" + publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: './', reportFiles: 'zap_report.html', reportName: 'OWASP ZAP Scan', reportTitles: 'OWASP ZAP Scan']) } } } From 68e18899b54e65b8adb3cdb8298f93c5520739ca Mon Sep 17 00:00:00 2001 From: cubecc Date: Wed, 10 Jun 2020 17:58:12 +0800 Subject: [PATCH 103/121] dasd --- Jenkinsfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c9e068d..fd374a6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -161,10 +161,11 @@ pipeline { stage('OWASP Scan') { steps { script { - //runLog = sh (script: "docker run --user \$(id -u):\$(id -g) -v ${workspace}:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html", returnStatus: true) - runLog = sh (script: "docker run --user \$(id -u):\$(id -g) -v ${workspace}:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://www.yahoo.com.hk -r zap_report.html", returnStatus: true) - //echo "ZAP Run Log: ${runLog}" + runLog = sh (script: "docker run --user \$(id -u):\$(id -g) -v ${workspace}:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html -m 5", returnStatus: true) publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: './', reportFiles: 'zap_report.html', reportName: 'OWASP ZAP Scan', reportTitles: 'OWASP ZAP Scan']) + + //0 if there are no issues, 1 if there are any failures or 2 if there are just warning + echo "ZAP Run Log: ${runLog}" } } } From d96216beed52c6a1544fb223985290af8a821168 Mon Sep 17 00:00:00 2001 From: cubecc Date: Fri, 12 Jun 2020 12:04:09 +0800 Subject: [PATCH 104/121] czxcxc --- Jenkinsfile | 28 ++++++++++++++++------------ webdemo.yaml | 22 +++++++++++----------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fd374a6..3e31f4f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,12 +8,15 @@ pipeline { //registryCredential = 'docker-registry-100.64.21.108' registryCredential = 'docker-registry-login' //dockerImage = '' - env= "dev" + //env= "dev" //IMAGE = readMavenPom().getArtifactId() //VERSION = readMavenPom().getVersion() - appname = "webdemo-dev" - IMAGE = "registry.lab.local:5000/${appname}" - VERSION = "${BUILD_NUMBER}" + appname = "webdemo" + //IMAGE = "registry.lab.local:5000/${appname}" + //VERSION = "${BUILD_NUMBER}" + + VERSION = "${env.BUILD_ID}-${env.GIT_COMMIT}" + IMAGE = "registry.lab.local:5000/${appname}" } tools { @@ -21,7 +24,7 @@ pipeline { } stages { - /* + stage('User Input') { steps { echo 'wait user input...' @@ -50,12 +53,13 @@ pipeline { stage('Build & Test') { steps { //sh 'mvn clean package -P${env} -DskipTests' - sh 'mvn clean package -P${env}' + //sh 'mvn clean package -P${env}' + sh 'mvn clean package' } post { success { //echo 'generate test report' - junit 'target/surefire-reports//*.xml' + junit 'target/surefire-reports/**/*.xml' } } } @@ -118,7 +122,8 @@ pipeline { stage('Deploy to K8') { steps{ sh ''' - kubectl replace -f webdemo.yaml --force + envsubst < webdemo.yaml > webdemo_out.yaml + kubectl replace -f webdemo_out.yaml --force kubectl rollout status deployment ${appname} --watch --timeout=5m ''' } @@ -155,8 +160,7 @@ pipeline { } } } - } - */ + } stage('OWASP Scan') { steps { @@ -170,7 +174,7 @@ pipeline { } } - stage('Post test') { + stage('Smoke Test') { steps{ echo 'ping curl...' } @@ -180,7 +184,7 @@ pipeline { post { always { echo 'post status : clearup workspace' - //deleteDir() /* clean up our workspace */ + deleteDir() /* clean up our workspace */ } success { echo 'post status : success' diff --git a/webdemo.yaml b/webdemo.yaml index fd6813c..932c61a 100644 --- a/webdemo.yaml +++ b/webdemo.yaml @@ -3,27 +3,27 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: webdemo-dev + name: ${appname} spec: replicas: 1 selector: matchLabels: - app: webdemo-dev + app: ${appname} template: metadata: labels: - app: webdemo-dev + app: ${appname} spec: containers: - - name: webdemo - image: registry.lab.local:5000/webdemo-dev:latest + - name: ${appname} + image: ${IMAGE}:${VERSION} imagePullPolicy: Always env: - name: env value: "testing" ports: - containerPort: 18080 - name: webdemo-dev + name: ${appname} protocol: TCP resources: limits: @@ -45,13 +45,13 @@ spec: apiVersion: v1 kind: Service metadata: - name: webdemo-dev + name: ${appname} spec: selector: - app: webdemo-dev + app: ${appname} type: NodePort ports: - - name: webdemo-dev + - name: ${appname} port: 18080 nodePort: 31235 @@ -60,12 +60,12 @@ spec: apiVersion: autoscaling/v1 kind: HorizontalPodAutoscaler metadata: - name: webdemo-dev + name: ${appname} spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment - name: webdemo-dev + name: ${appname} minReplicas: 1 maxReplicas: 10 targetCPUUtilizationPercentage: 50 From 05a8ac2950f1d6b236fa504f1bc4f958877c2afd Mon Sep 17 00:00:00 2001 From: cubecc Date: Fri, 12 Jun 2020 12:05:08 +0800 Subject: [PATCH 105/121] asdasd --- Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 3e31f4f..4d0e85f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -138,6 +138,7 @@ pipeline { // } //} + /* stage('OWASP Scan') { agent { label 'zap' } options { skipDefaultCheckout() } @@ -161,6 +162,7 @@ pipeline { } } } +*/ stage('OWASP Scan') { steps { From 12018a44483cfc04296e36f216c3f119deb74cb0 Mon Sep 17 00:00:00 2001 From: cubecc Date: Fri, 12 Jun 2020 12:21:16 +0800 Subject: [PATCH 106/121] dsad --- Jenkinsfile | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4d0e85f..c53480c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -54,7 +54,7 @@ pipeline { steps { //sh 'mvn clean package -P${env} -DskipTests' //sh 'mvn clean package -P${env}' - sh 'mvn clean package' + sh 'mvn clean package -DskipTests' } post { success { @@ -128,16 +128,7 @@ pipeline { ''' } } - - //stage('Build and Publish Image') { - //} - - //stage ('clean after working'){ - // steps{ - // deleteDir() - // } - //} - + /* stage('OWASP Scan') { agent { label 'zap' } From 3795f0ca016183b49ae53bef8b6bb5d5c0911336 Mon Sep 17 00:00:00 2001 From: cubecc Date: Fri, 12 Jun 2020 12:22:43 +0800 Subject: [PATCH 107/121] dasd --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c53480c..d83b2fb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -58,8 +58,8 @@ pipeline { } post { success { - //echo 'generate test report' - junit 'target/surefire-reports/**/*.xml' + echo 'generate test report' + //junit 'target/surefire-reports/**/*.xml' } } } From 8bf16bcb57ceae6695912c812be0e2f9d9b50f91 Mon Sep 17 00:00:00 2001 From: cubecc Date: Fri, 12 Jun 2020 12:27:55 +0800 Subject: [PATCH 108/121] dadad --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d83b2fb..0e0c100 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -70,7 +70,7 @@ pipeline { //sh 'mvn sonar:sonar -Dsonar.login=$SONAR_PSW' withSonarQubeEnv('SonarQube'){ - sh 'mvn sonar:sonar' + sh 'mvn sonar:sonar -Dsonar.dependencyCheck.reportPath=target/dependency-check-report.xml' } } } From c82251411ac06a394d66ed7bcba52ff057de4fe4 Mon Sep 17 00:00:00 2001 From: cubecc Date: Fri, 12 Jun 2020 12:34:34 +0800 Subject: [PATCH 109/121] dasdasd --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0e0c100..8d44778 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -70,7 +70,7 @@ pipeline { //sh 'mvn sonar:sonar -Dsonar.login=$SONAR_PSW' withSonarQubeEnv('SonarQube'){ - sh 'mvn sonar:sonar -Dsonar.dependencyCheck.reportPath=target/dependency-check-report.xml' + sh 'mvn sonar:sonar -Dsonar.dependencyCheck.reportPath=target/dependency-check-report.xml -Dsonar.dependencyCheck.htmlReportPath=target/dependency-check-report.html' } } } From 41c86c54b6c860ea4e69722a19ba1c60b7127ce2 Mon Sep 17 00:00:00 2001 From: cubecc Date: Fri, 12 Jun 2020 12:42:18 +0800 Subject: [PATCH 110/121] dadsad --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8d44778..3936e92 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -70,7 +70,8 @@ pipeline { //sh 'mvn sonar:sonar -Dsonar.login=$SONAR_PSW' withSonarQubeEnv('SonarQube'){ - sh 'mvn sonar:sonar -Dsonar.dependencyCheck.reportPath=target/dependency-check-report.xml -Dsonar.dependencyCheck.htmlReportPath=target/dependency-check-report.html' + //sh 'mvn sonar:sonar -Dsonar.dependencyCheck.reportPath=target/dependency-check-report.xml -Dsonar.dependencyCheck.htmlReportPath=target/dependency-check-report.html' + sh 'mvn sonar:sonar' } } } From feeffe83da0f48bd4eeb2ad4cf8864de586e7d22 Mon Sep 17 00:00:00 2001 From: cubecc Date: Fri, 12 Jun 2020 12:45:14 +0800 Subject: [PATCH 111/121] dasd --- Jenkinsfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 3936e92..1f60c73 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -64,6 +64,12 @@ pipeline { } } + stage('Dep Check') { + steps{ + dependencyCheckAnalyzer datadir: '', hintsFile: '', includeCsvReports: false, includeHtmlReports: true, includeJsonReports: false, includeVulnReports: true, isAutoupdateDisabled: false, outdir: '', scanpath: '', skipOnScmChange: false, skipOnUpstreamChange: false, suppressionFile: '', zipExtensions: '' + } + } + stage('SonarQube Analysis') { steps { echo 'call sonar' From c2417240b3b24527a06ddcddaec68f6db4ad79e8 Mon Sep 17 00:00:00 2001 From: cubecc Date: Fri, 12 Jun 2020 12:51:23 +0800 Subject: [PATCH 112/121] dsad --- Jenkinsfile | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1f60c73..5f820bc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -64,11 +64,6 @@ pipeline { } } - stage('Dep Check') { - steps{ - dependencyCheckAnalyzer datadir: '', hintsFile: '', includeCsvReports: false, includeHtmlReports: true, includeJsonReports: false, includeVulnReports: true, isAutoupdateDisabled: false, outdir: '', scanpath: '', skipOnScmChange: false, skipOnUpstreamChange: false, suppressionFile: '', zipExtensions: '' - } - } stage('SonarQube Analysis') { steps { From b250f1f5e6f8518344d50588c6309b7165778718 Mon Sep 17 00:00:00 2001 From: cubecc Date: Fri, 12 Jun 2020 14:39:07 +0800 Subject: [PATCH 113/121] dasds --- Jenkinsfile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5f820bc..44ee56a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -27,6 +27,7 @@ pipeline { stage('User Input') { steps { + sh 'yum install gettext' echo 'wait user input...' // timeout(1) { // script { @@ -65,8 +66,16 @@ pipeline { } + stage('Dependency Check') { + steps { + dependencycheck additionalArguments: '- project [project_name]- scan ./ — out ./target/dependency-check-report.xml — format XML — noupdate', odcInstallation: 'Dependency Checker' + } + } + + stage('SonarQube Analysis') { steps { + echo 'call sonar' //sh 'mvn sonar:sonar -Dsonar.login=$SONAR_PSW' @@ -79,7 +88,7 @@ pipeline { stage("Quality Gate") { steps { - timeout(time: 1, unit: 'HOURS') { + timeout(time: 10, unit: 'MINUTES') { waitForQualityGate abortPipeline: true } } From 9ccd250227ccbfc6e7f1c9db232eb46baa664df5 Mon Sep 17 00:00:00 2001 From: cubecc Date: Fri, 12 Jun 2020 14:54:44 +0800 Subject: [PATCH 114/121] dasdsad --- Jenkinsfile | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 44ee56a..5d58d9c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,8 +26,7 @@ pipeline { stages { stage('User Input') { - steps { - sh 'yum install gettext' + steps { echo 'wait user input...' // timeout(1) { // script { @@ -68,7 +67,8 @@ pipeline { stage('Dependency Check') { steps { - dependencycheck additionalArguments: '- project [project_name]- scan ./ — out ./target/dependency-check-report.xml — format XML — noupdate', odcInstallation: 'Dependency Checker' + dependencycheck additionalArguments: '- project [project_name]- scan ./ - out ./target/dependency-check-report.xml - format XML - noupdate', odcInstallation: 'Dependency Checker' + //dependencyCheckPublisher pattern: './target/dependency-check-report.xml' } } @@ -132,9 +132,11 @@ pipeline { stage('Deploy to K8') { steps{ + //envsubst < webdemo.yaml > webdemo_out.yaml sh ''' - envsubst < webdemo.yaml > webdemo_out.yaml - kubectl replace -f webdemo_out.yaml --force + + sed -i -e "s/\${appname}/${appname}/g;s/\${IMAGE}/${IMAGE}/g;s/\${VERSION}/${VERSION}/g;" webdemo.yaml + kubectl replace -f webdemo.yaml --force kubectl rollout status deployment ${appname} --watch --timeout=5m ''' } From 49734b3f585cb9d040dafb0e01327c2f9f6c245e Mon Sep 17 00:00:00 2001 From: cubecc Date: Fri, 12 Jun 2020 15:06:41 +0800 Subject: [PATCH 115/121] dasd --- Jenkinsfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5d58d9c..b0e253f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -106,14 +106,15 @@ pipeline { } } } - + + /* stage('Docker security analysis'){ steps { echo 'Performing Docker image analysis' //sh "CLAIR_ADDR=localhost:6060 CLAIR_OUTPUT=High CLAIR_THRESHOLD=100 /home/yyy/ ${IMAGE}:${VERSION}" } } - + */ stage('Push Docker Images') { @@ -135,7 +136,7 @@ pipeline { //envsubst < webdemo.yaml > webdemo_out.yaml sh ''' - sed -i -e "s/\${appname}/${appname}/g;s/\${IMAGE}/${IMAGE}/g;s/\${VERSION}/${VERSION}/g;" webdemo.yaml + sed -i -e "s/\\${appname}/${appname}/g;s/\\${IMAGE}/${IMAGE}/g;s/\\${VERSION}/${VERSION}/g" webdemo.yaml kubectl replace -f webdemo.yaml --force kubectl rollout status deployment ${appname} --watch --timeout=5m ''' From c808ff0a84efbe1cdeee861ee0d9a31e3f871534 Mon Sep 17 00:00:00 2001 From: cubecc Date: Fri, 12 Jun 2020 15:15:59 +0800 Subject: [PATCH 116/121] dasd --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b0e253f..fc38efc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -136,7 +136,7 @@ pipeline { //envsubst < webdemo.yaml > webdemo_out.yaml sh ''' - sed -i -e "s/\\${appname}/${appname}/g;s/\\${IMAGE}/${IMAGE}/g;s/\\${VERSION}/${VERSION}/g" webdemo.yaml + sed -i -e "s~\\${appname}~${appname}~g;s~\\${IMAGE}~${IMAGE}~g;s~\\${VERSION}~${VERSION}~g" webdemo.yaml kubectl replace -f webdemo.yaml --force kubectl rollout status deployment ${appname} --watch --timeout=5m ''' From 361aa15d8f3aa2bd2d686d4f84399c4491bc7f35 Mon Sep 17 00:00:00 2001 From: cubecc Date: Fri, 12 Jun 2020 15:18:35 +0800 Subject: [PATCH 117/121] dsad --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fc38efc..e7a493a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -67,7 +67,7 @@ pipeline { stage('Dependency Check') { steps { - dependencycheck additionalArguments: '- project [project_name]- scan ./ - out ./target/dependency-check-report.xml - format XML - noupdate', odcInstallation: 'Dependency Checker' + dependencycheck additionalArguments: '- project [project_name]- scan ./ - out ./target/dependency-check-report.html - format html - noupdate', odcInstallation: 'Dependency Checker' //dependencyCheckPublisher pattern: './target/dependency-check-report.xml' } } @@ -191,7 +191,7 @@ pipeline { post { always { echo 'post status : clearup workspace' - deleteDir() /* clean up our workspace */ + //deleteDir() /* clean up our workspace */ } success { echo 'post status : success' From bf46faa185e36dfec841df3f2501804550f6e815 Mon Sep 17 00:00:00 2001 From: cubecc Date: Fri, 12 Jun 2020 15:28:10 +0800 Subject: [PATCH 118/121] dsad --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index e7a493a..4aea951 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -67,7 +67,7 @@ pipeline { stage('Dependency Check') { steps { - dependencycheck additionalArguments: '- project [project_name]- scan ./ - out ./target/dependency-check-report.html - format html - noupdate', odcInstallation: 'Dependency Checker' + dependencycheck additionalArguments: '--project [project_name] --scan ./ --out ./target/dependency-check-report.html --format HTML --noupdate', odcInstallation: 'Dependency Checker' //dependencyCheckPublisher pattern: './target/dependency-check-report.xml' } } From f1d04ac69d4fa451ae35b6361e94d3ae48eaf971 Mon Sep 17 00:00:00 2001 From: cubecc Date: Fri, 12 Jun 2020 15:37:10 +0800 Subject: [PATCH 119/121] dasds --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4aea951..071c6ea 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -80,8 +80,8 @@ pipeline { //sh 'mvn sonar:sonar -Dsonar.login=$SONAR_PSW' withSonarQubeEnv('SonarQube'){ - //sh 'mvn sonar:sonar -Dsonar.dependencyCheck.reportPath=target/dependency-check-report.xml -Dsonar.dependencyCheck.htmlReportPath=target/dependency-check-report.html' - sh 'mvn sonar:sonar' + sh 'mvn sonar:sonar -Dsonar.dependencyCheck.reportPath=target/dependency-check-report.html -Dsonar.dependencyCheck.htmlReportPath=target/dependency-check-report.html' + //sh 'mvn sonar:sonar' } } } From ecaaa4b73d83a61fde66ec534f1d5463101ff982 Mon Sep 17 00:00:00 2001 From: cubecc Date: Fri, 12 Jun 2020 23:05:19 +0800 Subject: [PATCH 120/121] dsada --- Jenkinsfile | 86 +++++++++++++++++++++++++++++++++------------------- webdemo.yaml | 24 +++++++-------- 2 files changed, 66 insertions(+), 44 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 071c6ea..c25b2d7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,3 +1,11 @@ +def getEnvFromBranch(branch) { + if (branch == 'master') { + return 'prod' + } else { + return branch + } +} + pipeline { agent any @@ -7,16 +15,26 @@ pipeline { registryUrl = 'https://registry.lab.local:5000' //registryCredential = 'docker-registry-100.64.21.108' registryCredential = 'docker-registry-login' - //dockerImage = '' - //env= "dev" - //IMAGE = readMavenPom().getArtifactId() - //VERSION = readMavenPom().getVersion() - appname = "webdemo" - //IMAGE = "registry.lab.local:5000/${appname}" - //VERSION = "${BUILD_NUMBER}" + //dockerDOCKER_IMAGE_NAME = '' + + ENV_NAME = getEnvFromBranch(${env.BRANCH_NAME}) + + APP_NAME = "webdemo-${ENV_NAME}" + APP_VERSION = "MAK001"; + + //DOCKER_IMAGE_NAME = readMavenPom().getArtifactId() + //DOCKER_IMAGE_VERSION = readMavenPom().getVersion() + //DOCKER_IMAGE_NAME = "registry.lab.local:5000/${APP_NAME}" + //DOCKER_IMAGE_VERSION = "${BUILD_NUMBER}" - VERSION = "${env.BUILD_ID}-${env.GIT_COMMIT}" - IMAGE = "registry.lab.local:5000/${appname}" + //BUILD_ENV = "${BRANCH_NAME}" + + DOCKER_IMAGE_NAME = "registry.lab.local:5000/${APP_NAME}" + //DOCKER_IMAGE_VERSION = "${env.BRANCH_NAME}-${APP_VERSION}-${env.BUILD_ID}-${env.GIT_COMMIT}" + DOCKER_IMAGE_VERSION = "${env.BRANCH_NAME}-${APP_VERSION}-${env.GIT_COMMIT}" + + HOST = "100.64.21.141" + HOST_PORT = "31235" } tools { @@ -42,24 +60,25 @@ pipeline { stage ('Initialize') { steps { - sh ''' - echo "PATH = ${PATH}" - echo "M2_HOME = ${M2_HOME}" - echo "" - ''' - } + //sh ''' + // echo "PATH = ${PATH}" + // echo "M2_HOME = ${M2_HOME}" + // echo "" + //''' + echo 'init' + } } stage('Build & Test') { steps { //sh 'mvn clean package -P${env} -DskipTests' - //sh 'mvn clean package -P${env}' - sh 'mvn clean package -DskipTests' + sh 'mvn clean package' + //sh 'mvn clean package -DskipTests' } post { success { echo 'generate test report' - //junit 'target/surefire-reports/**/*.xml' + junit 'target/surefire-reports/**/*.xml' } } } @@ -88,19 +107,19 @@ pipeline { stage("Quality Gate") { steps { - timeout(time: 10, unit: 'MINUTES') { + timeout(time: 15, unit: 'MINUTES') { waitForQualityGate abortPipeline: true } } } - stage('Build Docker Images') { + stage('Build Docker DOCKER_IMAGE_NAMEs') { steps { script { docker.withRegistry( registryUrl, registryCredential ) { sh ''' - docker build -t ${IMAGE}:${VERSION} . + docker build -t ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION} . ''' } } @@ -110,21 +129,22 @@ pipeline { /* stage('Docker security analysis'){ steps { - echo 'Performing Docker image analysis' - //sh "CLAIR_ADDR=localhost:6060 CLAIR_OUTPUT=High CLAIR_THRESHOLD=100 /home/yyy/ ${IMAGE}:${VERSION}" + echo 'Performing Docker DOCKER_IMAGE_NAME analysis' + //sh "CLAIR_ADDR=localhost:6060 CLAIR_OUTPUT=High CLAIR_THRESHOLD=100 /home/yyy/ ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION}" } } */ - stage('Push Docker Images') { + stage('Push Docker Image') { steps { script { docker.withRegistry( registryUrl, registryCredential ) { - sh ''' - docker tag ${IMAGE}:${VERSION} ${IMAGE}:latest - docker push ${IMAGE}:${VERSION} - docker push ${IMAGE}:latest + //docker tag ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION} ${DOCKER_IMAGE_NAME}:latest + //docker push ${DOCKER_IMAGE_NAME}:latest + sh ''' + docker push ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION} + docker rmi ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION} ''' } } @@ -136,9 +156,11 @@ pipeline { //envsubst < webdemo.yaml > webdemo_out.yaml sh ''' - sed -i -e "s~\\${appname}~${appname}~g;s~\\${IMAGE}~${IMAGE}~g;s~\\${VERSION}~${VERSION}~g" webdemo.yaml + sed -i -e "s~\\${APP_NAME}~${APP_NAME}~g;s~\\${DOCKER_IMAGE_NAME}~${DOCKER_IMAGE_NAME}~g;s~\\${DOCKER_IMAGE_VERSION}~${DOCKER_IMAGE_VERSION}~g" webdemo.yaml + sed -i -e "s~\\${HOST_PORT}~${HOST_PORT}~g" webdemo.yaml + kubectl replace -f webdemo.yaml --force - kubectl rollout status deployment ${appname} --watch --timeout=5m + kubectl rollout status deployment ${APP_NAME} --watch --timeout=5m ''' } } @@ -172,7 +194,7 @@ pipeline { stage('OWASP Scan') { steps { script { - runLog = sh (script: "docker run --user \$(id -u):\$(id -g) -v ${workspace}:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://100.64.21.141:31235/ -r zap_report.html -m 5", returnStatus: true) + runLog = sh (script: "docker run --user \$(id -u):\$(id -g) -v ${workspace}:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://${HOST}:${HOST_IP} -r zap_report.html -m 5", returnStatus: true) publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: './', reportFiles: 'zap_report.html', reportName: 'OWASP ZAP Scan', reportTitles: 'OWASP ZAP Scan']) //0 if there are no issues, 1 if there are any failures or 2 if there are just warning @@ -191,7 +213,7 @@ pipeline { post { always { echo 'post status : clearup workspace' - //deleteDir() /* clean up our workspace */ + deleteDir() /* clean up our workspace */ } success { echo 'post status : success' diff --git a/webdemo.yaml b/webdemo.yaml index 932c61a..74333e3 100644 --- a/webdemo.yaml +++ b/webdemo.yaml @@ -3,27 +3,27 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: ${appname} + name: ${APP_NAME} spec: replicas: 1 selector: matchLabels: - app: ${appname} + app: ${APP_NAME} template: metadata: labels: - app: ${appname} + app: ${APP_NAME} spec: containers: - - name: ${appname} - image: ${IMAGE}:${VERSION} + - name: ${APP_NAME} + DOCKER_IMAGE_NAME: ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION} imagePullPolicy: Always env: - name: env value: "testing" ports: - containerPort: 18080 - name: ${appname} + name: ${APP_NAME} protocol: TCP resources: limits: @@ -45,27 +45,27 @@ spec: apiVersion: v1 kind: Service metadata: - name: ${appname} + name: ${APP_NAME} spec: selector: - app: ${appname} + app: ${APP_NAME} type: NodePort ports: - - name: ${appname} + - name: ${APP_NAME} port: 18080 - nodePort: 31235 + nodePort: ${HOST_PORT} --- apiVersion: autoscaling/v1 kind: HorizontalPodAutoscaler metadata: - name: ${appname} + name: ${APP_NAME} spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment - name: ${appname} + name: ${APP_NAME} minReplicas: 1 maxReplicas: 10 targetCPUUtilizationPercentage: 50 From 09f3c1fc9ab435f3b08490552443ece84d6fc78d Mon Sep 17 00:00:00 2001 From: cubecc Date: Fri, 12 Jun 2020 23:08:44 +0800 Subject: [PATCH 121/121] dasds --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c25b2d7..59a1b06 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,7 +17,7 @@ pipeline { registryCredential = 'docker-registry-login' //dockerDOCKER_IMAGE_NAME = '' - ENV_NAME = getEnvFromBranch(${env.BRANCH_NAME}) + ENV_NAME = getEnvFromBranch("${env.BRANCH_NAME}") APP_NAME = "webdemo-${ENV_NAME}" APP_VERSION = "MAK001"; @@ -105,7 +105,7 @@ pipeline { } } - stage("Quality Gate") { + stage('Quality Gate') { steps { timeout(time: 15, unit: 'MINUTES') { waitForQualityGate abortPipeline: true