From 4b0e9eac1a1952dc7576c5775548ecefbba583da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Pailloncy?= Date: Mon, 6 Mar 2017 17:10:17 +0100 Subject: [PATCH 01/10] Add Jenkinsfile --- Jenkinsfile | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..7a6b24c45 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,52 @@ +pipeline { + + agent { label "build" } + + tools { + maven "M3" + } + + stages { + + stage("prepare") { + steps { + checkout scm + } + } + + stage("build") { + steps { + sh "mvn clean package" + } + post { + always { + archive "target/*.jar" + junit 'target/surefire-reports/*.xml' + stash includes:"target/*.jar", name: "binary" + } + } + } + + stage("tests") { + steps { + parallel ( + "static-analysis" : { + withSonarQubeEnv('sonarqube') { + sh 'mvn sonar:sonar' + } + }, + "performance-tests": { + echo "performance tests" + } + ) + } + } + + stage("deploy") { + steps { + unstash name:"binary" + input "Deploy ?" + } + } + } +} From a6f76c59a7f73a267ae1b6ecbd4b77cff80e58d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Pailloncy?= Date: Mon, 6 Mar 2017 17:27:26 +0100 Subject: [PATCH 02/10] Split stages in different nodes --- Jenkinsfile | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7a6b24c45..bfcfc711b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,6 @@ pipeline { - agent { label "build" } + agent any tools { maven "M3" @@ -15,6 +15,7 @@ pipeline { } stage("build") { + agent { label: "build" } steps { sh "mvn clean package" } @@ -22,7 +23,8 @@ pipeline { always { archive "target/*.jar" junit 'target/surefire-reports/*.xml' - stash includes:"target/*.jar", name: "binary" + stash includes: "**", name: "sources" + stash includes: "target/*.jar", name: "binary" } } } @@ -31,20 +33,28 @@ pipeline { steps { parallel ( "static-analysis" : { - withSonarQubeEnv('sonarqube') { - sh 'mvn sonar:sonar' + node("build") { + unstash "sources" + withSonarQubeEnv('sonarqube') { + sh 'mvn sonar:sonar' + } } }, "performance-tests": { - echo "performance tests" + node("build") { + echo "performance tests" + sleep 20 + } } ) } } stage("deploy") { + agent { label "ssh" } steps { unstash name:"binary" + sh "ls -rtl target/" input "Deploy ?" } } From 7b1f95e91bec9db2d968313198640cce8735c244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Pailloncy?= Date: Mon, 6 Mar 2017 17:31:00 +0100 Subject: [PATCH 03/10] Fix syntax error --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index bfcfc711b..2f4f19f28 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,7 +15,7 @@ pipeline { } stage("build") { - agent { label: "build" } + agent { label "build" } steps { sh "mvn clean package" } From c1093264739aa2b1f0586b036fde5bb03b58a92c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Pailloncy?= Date: Mon, 6 Mar 2017 17:35:12 +0100 Subject: [PATCH 04/10] Fix maven path error --- Jenkinsfile | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2f4f19f28..4e2f08080 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,11 +1,7 @@ pipeline { agent any - - tools { - maven "M3" - } - + stages { stage("prepare") { @@ -15,10 +11,17 @@ pipeline { } stage("build") { + agent { label "build" } + + tools { + maven "M3" + } + steps { sh "mvn clean package" } + post { always { archive "target/*.jar" @@ -35,8 +38,10 @@ pipeline { "static-analysis" : { node("build") { unstash "sources" - withSonarQubeEnv('sonarqube') { - sh 'mvn sonar:sonar' + withMaven("M3") { + withSonarQubeEnv('sonarqube') { + sh 'mvn sonar:sonar' + } } } }, From db33c0e41de81b96a10d1e4c32eb511b09ee5eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Pailloncy?= Date: Mon, 6 Mar 2017 17:41:58 +0100 Subject: [PATCH 05/10] Bim --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4e2f08080..26dae39ce 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -38,7 +38,7 @@ pipeline { "static-analysis" : { node("build") { unstash "sources" - withMaven("M3") { + withMaven(maven:"M3") { withSonarQubeEnv('sonarqube') { sh 'mvn sonar:sonar' } From 504f9fa523133201e9620423275df4098c037f2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Pailloncy?= Date: Mon, 6 Mar 2017 17:46:18 +0100 Subject: [PATCH 06/10] Remove duplicate checkout scm --- Jenkinsfile | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 26dae39ce..1e2af5402 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,12 +4,6 @@ pipeline { stages { - stage("prepare") { - steps { - checkout scm - } - } - stage("build") { agent { label "build" } From f3ba8fba2db17da0a6213e5bbb89823514af166f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Pailloncy?= Date: Mon, 6 Mar 2017 17:53:07 +0100 Subject: [PATCH 07/10] Change target agent during tests --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1e2af5402..50e7ec0dd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -40,7 +40,7 @@ pipeline { } }, "performance-tests": { - node("build") { + node("test") { echo "performance tests" sleep 20 } From 2ff6113dc2fec52046a459156e94c033798a5baf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Pailloncy?= Date: Mon, 6 Mar 2017 17:57:27 +0100 Subject: [PATCH 08/10] Bim --- Jenkinsfile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 50e7ec0dd..d660c89b1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -28,6 +28,7 @@ pipeline { stage("tests") { steps { + parallel ( "static-analysis" : { node("build") { @@ -42,19 +43,26 @@ pipeline { "performance-tests": { node("test") { echo "performance tests" + sh "ls -rtl" sleep 20 } } - ) + ) } } - + + stage("user-interaction") { + agent none + steps { + input "Deploy ?" + } + } + stage("deploy") { agent { label "ssh" } steps { unstash name:"binary" sh "ls -rtl target/" - input "Deploy ?" } } } From bb9b6e3e8ecce1bfa1d9f3743cfb4fe57442739e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Pailloncy?= Date: Mon, 6 Mar 2017 18:06:25 +0100 Subject: [PATCH 09/10] Try to enable parallel --- Jenkinsfile | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d660c89b1..89be8b24e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,6 @@ pipeline { - - agent any + + agent none stages { @@ -28,26 +28,25 @@ pipeline { stage("tests") { steps { - - parallel ( - "static-analysis" : { - node("build") { - unstash "sources" - withMaven(maven:"M3") { - withSonarQubeEnv('sonarqube') { - sh 'mvn sonar:sonar' + parallel ( + "static-analysis": { + node("build") { + unstash "sources" + withMaven(maven:"M3") { + withSonarQubeEnv('sonarqube') { + sh 'mvn sonar:sonar' + } + } + } + }, + "performance-tests": { + node("test") { + echo "performance tests" + sh "ls -rtl" + sleep 20 } } - } - }, - "performance-tests": { - node("test") { - echo "performance tests" - sh "ls -rtl" - sleep 20 - } - } - ) + ) } } From 5db073f0229301dc8301eb955dd573282afd2ed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Pailloncy?= Date: Mon, 6 Mar 2017 20:00:13 +0100 Subject: [PATCH 10/10] Heuu --- Jenkinsfile | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 89be8b24e..b01454be6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -28,25 +28,26 @@ pipeline { stage("tests") { steps { - parallel ( - "static-analysis": { - node("build") { - unstash "sources" - withMaven(maven:"M3") { - withSonarQubeEnv('sonarqube') { - sh 'mvn sonar:sonar' - } + parallel ( + "static-analysis": { + node("build") { + unstash "sources" + withMaven(maven:"M3") { + withSonarQubeEnv('sonarqube') { + sh 'mvn sonar:sonar' } } - }, - "performance-tests": { - node("test") { - echo "performance tests" - sh "ls -rtl" - sleep 20 - } + sleep 30 } - ) + }, + "performance-tests": { + node("build") { + echo "performance tests" + sh "ls -rtl" + sleep 20 + } + } + ) } }