From 3b75d2c00f1757b593b5f2a7304e958b103d5592 Mon Sep 17 00:00:00 2001 From: smlsunxie Date: Wed, 30 May 2018 09:37:18 +0000 Subject: [PATCH 01/10] save --- Jenkinsfile | 77 +---------------------------------------------------- 1 file changed, 1 insertion(+), 76 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3637de6..e08ccd0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,91 +6,16 @@ pipeline { checkout scm } } - stage('check env') { - parallel { - stage('check mvn') { - steps { - sh 'mvn -v' - } - } - stage('check java') { - steps { - sh 'java -version' - } - } - } - } - - stage('test') { - steps { - sh 'mvn test cobertura:cobertura' - } - } - stage('report') { - parallel { - stage('junit') { - steps { - junit '**/target/surefire-reports/TEST-*.xml' - } - } - stage('coverage') { - steps { - cobertura(coberturaReportFile: 'target/site/cobertura/coverage.xml') - } - } - } - } - stage('package') { - steps { - sh 'mvn package' - } - } - stage('stage') { - input { - message "Should we continue?" - ok "Yes, we should." - submitter "admin" - parameters { - string(name: 'PERSON', defaultValue: 'Mr Jenkins', description: 'Who should I say hello to?') - } - } - steps { - echo "Hello, ${PERSON}, nice to meet you." - sh 'make deploy-default' - } - } - stage('preview') { - input { - message "Should we continue?" - ok "Yes, we should." - submitter "admin" - } - steps { - echo "every thing is good!" - } - } - stage('artifact') { - steps { - archiveArtifacts(artifacts: '**/target/*.jar', fingerprint: true) - } - } - stage('deploy') { - steps { - sh 'make deploy-default' - } - } - } + } post { always { echo 'I will always say Hello again!' } success { echo 'success!' - // slackSend channel: '#integration', color: 'good', message: "success ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)", teamDomain: 'agileworks-tw', token: 'JhXFKEl6cBFoQ4v52BEJw9Mr' } failure { echo 'failure!' - // slackSend channel: '#integration', color: 'danger', message: "fail ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)", teamDomain: 'agileworks-tw', token: 'JhXFKEl6cBFoQ4v52BEJw9Mr' } } } \ No newline at end of file From 28c5ddb66ad9f5bb1c82a4e3a810586084af2a4e Mon Sep 17 00:00:00 2001 From: SY_Huang <36390674+SyHuangCBN@users.noreply.github.com> Date: Thu, 7 Jun 2018 10:25:09 +0800 Subject: [PATCH 02/10] Added Jenkinsfile --- Jenkinsfile | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e08ccd0..d15ba9b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,18 +4,25 @@ pipeline { stage('checkout project') { steps { checkout scm + sh 'mvn cobertura:cobertura test' } } - } - post { - always { + } + post { + always { echo 'I will always say Hello again!' + } - success { + + success { echo 'success!' - } - failure { + + } + + failure { echo 'failure!' + } - } + + } } \ No newline at end of file From bac2a7e154adc48e8ec35d1dc2f6f53c25bd950e Mon Sep 17 00:00:00 2001 From: SY_Huang <36390674+SyHuangCBN@users.noreply.github.com> Date: Thu, 7 Jun 2018 10:31:56 +0800 Subject: [PATCH 03/10] Test --- Jenkinsfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index d15ba9b..7a75109 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,6 +7,11 @@ pipeline { sh 'mvn cobertura:cobertura test' } } + stage('TEST') { + steps { + sh 'mvn cobertura:cobertura test' + } + } } post { always { From 9c4f212dc3ff2ed591edd8d0b81a3e11f4c0f995 Mon Sep 17 00:00:00 2001 From: SY_Huang <36390674+SyHuangCBN@users.noreply.github.com> Date: Thu, 7 Jun 2018 10:35:05 +0800 Subject: [PATCH 04/10] report --- Jenkinsfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 7a75109..c64f5dd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,6 +12,20 @@ pipeline { sh 'mvn cobertura:cobertura test' } } + stage('Report') { + parallel { + stage('Report') { + steps { + sh 'target/surefire-reports/*.xml' + } + } + stage('') { + steps { + sh 'target/site/cobertura/coverage.xml' + } + } + } + } } post { always { From 6ffa7a5b084407ccc1476b71aa43248dea25e29c Mon Sep 17 00:00:00 2001 From: SY_Huang <36390674+SyHuangCBN@users.noreply.github.com> Date: Thu, 7 Jun 2018 10:41:44 +0800 Subject: [PATCH 05/10] tesst_sstep2 --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c64f5dd..4cc6bee 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,12 +16,12 @@ pipeline { parallel { stage('Report') { steps { - sh 'target/surefire-reports/*.xml' + junit 'target/surefire-reports/*.xml' } } - stage('') { + stage('Report2') { steps { - sh 'target/site/cobertura/coverage.xml' + cobertura(coberturaReportFile: 'target/site/cobertura/coverage.xml') } } } From 7f00b246c4bcdddc54204c23dd6785ddf7410383 Mon Sep 17 00:00:00 2001 From: SY_Huang <36390674+SyHuangCBN@users.noreply.github.com> Date: Thu, 7 Jun 2018 10:48:55 +0800 Subject: [PATCH 06/10] Added Jenkinsfile --- Jenkinsfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 4cc6bee..1a325f0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,6 +26,11 @@ pipeline { } } } + stage('package') { + steps { + archiveArtifacts(artifacts: 'mvn package', allowEmptyArchive: true) + } + } } post { always { From 2c6a2e8f61919b3a7a3f267353464dc48445418c Mon Sep 17 00:00:00 2001 From: SY_Huang <36390674+SyHuangCBN@users.noreply.github.com> Date: Thu, 7 Jun 2018 10:53:32 +0800 Subject: [PATCH 07/10] Added Jenkinsfile --- Jenkinsfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1a325f0..0f89d99 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,11 +7,6 @@ pipeline { sh 'mvn cobertura:cobertura test' } } - stage('TEST') { - steps { - sh 'mvn cobertura:cobertura test' - } - } stage('Report') { parallel { stage('Report') { @@ -26,9 +21,14 @@ pipeline { } } } - stage('package') { + stage('Package') { + steps { + sh 'mvn package' + } + } + stage('Artiche') { steps { - archiveArtifacts(artifacts: 'mvn package', allowEmptyArchive: true) + archiveArtifacts 'target/*.jar' } } } From 1529928857c1faf1bbdb0cd4b250ea8cf6e3b71f Mon Sep 17 00:00:00 2001 From: SY_Huang <36390674+SyHuangCBN@users.noreply.github.com> Date: Thu, 7 Jun 2018 11:02:22 +0800 Subject: [PATCH 08/10] Added Jenkinsfile --- Jenkinsfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 0f89d99..09c8cbe 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -31,6 +31,11 @@ pipeline { archiveArtifacts 'target/*.jar' } } + stage('Deploy') { + steps { + sh 'make deploy-default' + } + } } post { always { From 090138b45e46967881d1baab6bd5e3e1954102b3 Mon Sep 17 00:00:00 2001 From: syhuangcbn Date: Thu, 7 Jun 2018 03:41:59 +0000 Subject: [PATCH 09/10] add stage wait for confirm --- Jenkinsfile | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 09c8cbe..fcdb5b6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -31,6 +31,19 @@ pipeline { archiveArtifacts 'target/*.jar' } } + stage('wait for confirm') { + input { + message "Should we deploy?" + ok "Yes, we should." + submitter "admin" + parameters { + string(name: 'PERSON', defaultValue: 'Mr Jenkins', description: 'Who should I say hello to?') + } + } + steps { + echo "Hello, ${PERSON}, nice to meet you." + } + } stage('Deploy') { steps { sh 'make deploy-default' From f0f9a42f964d4cd53f1c74c293bd46e657405f59 Mon Sep 17 00:00:00 2001 From: SY_Huang <36390674+SyHuangCBN@users.noreply.github.com> Date: Thu, 7 Jun 2018 16:19:21 +0800 Subject: [PATCH 10/10] Added Jenkinsfile --- Jenkinsfile | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fcdb5b6..5c9be77 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,7 @@ pipeline { stage('checkout project') { steps { checkout scm - sh 'mvn cobertura:cobertura test' + sh 'docker run -v `pwd`:/app -v $HOME/.m2:/root/.m2 -w /app localhost:5000/maven mvn cobertura:cobertura test' } } stage('Report') { @@ -23,7 +23,7 @@ pipeline { } stage('Package') { steps { - sh 'mvn package' + sh 'docker run -v `pwd`:/app -v $HOME/.m2:/root/.m2 -w /app -p 8800:8000 localhost:5000/maven mvn package' } } stage('Artiche') { @@ -32,21 +32,25 @@ pipeline { } } stage('wait for confirm') { - input { - message "Should we deploy?" - ok "Yes, we should." - submitter "admin" - parameters { - string(name: 'PERSON', defaultValue: 'Mr Jenkins', description: 'Who should I say hello to?') - } - } - steps { - echo "Hello, ${PERSON}, nice to meet you." + input { + message 'Should we deploy?' + id 'Yes, we should.' + submitter 'admin' + parameters { + string(name: 'PERSON', defaultValue: 'Mr Jenkins', description: 'Who should I say hello to?') } + } + steps { + echo "Hello, ${PERSON}, nice to meet you." + } } stage('Deploy') { steps { - sh 'make deploy-default' + sh '''docker build -t localhost:5000/spring-boot-sample-prod ./ +docker push localhost:5000/spring-boot-sample-prod +docker pull localhost:5000/spring-boot-sample-prod +docker run -d -p 8800:8000 localhost:5000/spring-boot-sample-prod +''' } } }