From 3b75d2c00f1757b593b5f2a7304e958b103d5592 Mon Sep 17 00:00:00 2001 From: smlsunxie Date: Wed, 30 May 2018 09:37:18 +0000 Subject: [PATCH 01/13] 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 a245765822b4ccefd76acfaf04635d66d9a4c279 Mon Sep 17 00:00:00 2001 From: MartinCBN <39143132+MartinCBN@users.noreply.github.com> Date: Thu, 7 Jun 2018 10:24:19 +0800 Subject: [PATCH 02/13] test step --- Jenkinsfile | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e08ccd0..34e5cc7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,16 +6,27 @@ pipeline { checkout scm } } - } - post { - always { + stage('test') { + steps { + sh 'mvn cobertura:cobertura test' + } + } + } + post { + always { echo 'I will always say Hello again!' + } - success { + + success { echo 'success!' - } - failure { + + } + + failure { echo 'failure!' + } - } + + } } \ No newline at end of file From 711deee194e29249170c69438ccdb154fda6b21c Mon Sep 17 00:00:00 2001 From: MartinCBN <39143132+MartinCBN@users.noreply.github.com> Date: Thu, 7 Jun 2018 10:33:54 +0800 Subject: [PATCH 03/13] add report export --- Jenkinsfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 34e5cc7..c051066 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,6 +11,20 @@ pipeline { sh 'mvn cobertura:cobertura test' } } + stage('report') { + parallel { + stage('report') { + steps { + junit 'target/surefire-reports/*.xml' + } + } + stage('converge') { + steps { + cobertura(coberturaReportFile: 'target/site/cobertura/coverage.xml') + } + } + } + } } post { always { From b07aaa0c4d4c731f61649660de551a7f1f4c9f8a Mon Sep 17 00:00:00 2001 From: MartinCBN <39143132+MartinCBN@users.noreply.github.com> Date: Thu, 7 Jun 2018 10:49:59 +0800 Subject: [PATCH 04/13] package --- Jenkinsfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index c051066..27cd51e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,6 +25,11 @@ pipeline { } } } + stage('package') { + steps { + archiveArtifacts 'mvn package' + } + } } post { always { From a66019bd7279fa206e7922bd1d073a8b7d9758f0 Mon Sep 17 00:00:00 2001 From: MartinCBN <39143132+MartinCBN@users.noreply.github.com> Date: Thu, 7 Jun 2018 10:51:31 +0800 Subject: [PATCH 05/13] package --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 27cd51e..a65a9df 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -27,7 +27,7 @@ pipeline { } stage('package') { steps { - archiveArtifacts 'mvn package' + sh 'mvn package' } } } From 747a094bc93b72e9f5ec8eec59de13677e3f1494 Mon Sep 17 00:00:00 2001 From: MartinCBN <39143132+MartinCBN@users.noreply.github.com> Date: Thu, 7 Jun 2018 10:53:36 +0800 Subject: [PATCH 06/13] end --- Jenkinsfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index a65a9df..5321f4d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -30,6 +30,11 @@ pipeline { sh 'mvn package' } } + stage('end') { + steps { + archiveArtifacts 'file location: target/*.jar' + } + } } post { always { From cf58125ce64cb433646d5c5f1a189bd74080677a Mon Sep 17 00:00:00 2001 From: MartinCBN <39143132+MartinCBN@users.noreply.github.com> Date: Thu, 7 Jun 2018 10:56:41 +0800 Subject: [PATCH 07/13] archive --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5321f4d..3a36794 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -30,9 +30,9 @@ pipeline { sh 'mvn package' } } - stage('end') { + stage('archive') { steps { - archiveArtifacts 'file location: target/*.jar' + archiveArtifacts ' target/*.jar' } } } From b9a1d6901d520d529864d1b77ffae6aa3c9f3aec Mon Sep 17 00:00:00 2001 From: MartinCBN <39143132+MartinCBN@users.noreply.github.com> Date: Thu, 7 Jun 2018 11:03:18 +0800 Subject: [PATCH 08/13] deploy --- Jenkinsfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 3a36794..fbc3343 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -35,6 +35,11 @@ pipeline { archiveArtifacts ' target/*.jar' } } + stage('deploy') { + steps { + sh 'make deploy-default' + } + } } post { always { From 2bba3ce3b95caa3624b93f00b95265ae9cd3af52 Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 7 Jun 2018 03:48:09 +0000 Subject: [PATCH 09/13] add confirm --- Jenkinsfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index fbc3343..bd99ae3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -35,6 +35,20 @@ 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 56ba153ead7697411abf051e3ec53f1f277bf7c2 Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 7 Jun 2018 03:48:58 +0000 Subject: [PATCH 10/13] add cofirm --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index bd99ae3..789ab04 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -41,7 +41,7 @@ pipeline { ok "Yes, we should." submitter "admin" parameters { - string(name: 'PERSON', defaultValue: 'Mr Jenkins', description: 'Who should I say hello to?') + string(name: 'PERSON', defaultValue: 'Mr Jenkins', description: 'Who should I say hello to??') } } steps { From 38be1df729316d0c28bcd289841bb422e4dcbdd5 Mon Sep 17 00:00:00 2001 From: MartinCBN <39143132+MartinCBN@users.noreply.github.com> Date: Thu, 7 Jun 2018 16:22:10 +0800 Subject: [PATCH 11/13] docker --- Jenkinsfile | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 789ab04..3306ea6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,7 +8,8 @@ pipeline { } stage('test') { steps { - 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') { @@ -27,7 +28,8 @@ 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('archive') { @@ -36,22 +38,25 @@ pipeline { } } stage('wait for confirm') { - input { - message "Should we deploy?" - ok "Yes, we should." - submitter "admin" + 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??') + string(name: 'PERSON', defaultValue: 'Mr Jenkins', description: 'Who should I say hello to??') } + } + steps { + echo "Hello, ${PERSON}, nice to meet you." + } } - 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 +''' } } } From 021cce005744bf806fffac5a9cea25707f60f643 Mon Sep 17 00:00:00 2001 From: MartinCBN <39143132+MartinCBN@users.noreply.github.com> Date: Thu, 7 Jun 2018 16:31:49 +0800 Subject: [PATCH 12/13] test 2 From 6b6b7a515facf8c09a87e4e350ad2549bb9a7906 Mon Sep 17 00:00:00 2001 From: MartinCBN <39143132+MartinCBN@users.noreply.github.com> Date: Thu, 7 Jun 2018 16:35:25 +0800 Subject: [PATCH 13/13] docker1