diff --git a/Jenkinsfile b/Jenkinsfile index 97a7169b..6412fa50 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,7 +5,7 @@ node { stage('build') { //withEnv(["PATH+MAVEN=${tool 'apache-maven-3.3.9'}/bin"]) { - withEnv(["PATH+MAVEN=${tool 'mvn-3.6.0'}/bin"]) { + withEnv(["PATH+MAVEN=${tool 'mvn-3.8.6'}/bin"]) { sh 'mvn --version' sh "mvn clean ${params.testType}" } diff --git a/Jenkinsfile_0226 b/Jenkinsfile_0226 new file mode 100644 index 00000000..45472399 --- /dev/null +++ b/Jenkinsfile_0226 @@ -0,0 +1,82 @@ +properties([parameters( + [string(defaultValue: 'test', description: 'test or verify', name: 'testType', trim: true), + string(defaultValue: 'openjdk8', description: 'openjdk8, openjdk9, openjdk10', name: 'jdkVer', trim: true), + string(defaultValue: 'master', description: 'master, or failed', name: 'branch', trim: true) + ] + + )]) + +node { + stage("git") { + checkout scm + } + + manager.addShortText(params.jdkVer) + manager.addShortText(params.testType) + + stage('build') { + // , + // "PATH+JDK=${tool 'openjdk10'}/bin" + // mvn: mvn-3.3.9, mvn-3.6.0, mvn-3.6.2 + // jdk: openjdk8, openjdk9, openjdk10 + def jdk = tool params.jdkVer + withEnv(["PATH+MAVEN=${tool 'mvn-3.3.9'}/bin", + "JAVA_HOME=${jdk}"]) { + sh 'ls -al $JAVA_HOME' + sh 'mvn --version' + sh "mvn clean ${params.testType} -Dmaven.test.failure.ignore=true" + } + } + + stage('report') { + junit 'target/surefire-reports/*.xml' + jacoco execPattern: 'target/**.exec' + + // if failed tests exist + if (currentBuild.result == 'UNSTABLE') { + + manager.addShortText("you have got fails.") + mail bcc: '', body: "jenkins", cc: '', from: '', replyTo: '', subject: 'you have failed tests', to: '8ad5a8295e@nhnent.dooray.com', mimeType: "text/html" + + // dooray messenger + def messengerBody = "you have failed tests" + withCredentials([string(credentialsId: 'dooray_incoming_hookurl', variable: 'DOORAY_URL')]) { + + httpRequest httpMode: 'POST', + requestBody: """{"botName": "Jenkins Pipeline Training", "botIconImage": "https://static.dooray.com/static_images/dooray-bot.png", "text":"${messengerBody}", + "attachments" : [ + { + "title" : "jenkins", + "titleLink" : "${BUILD_URL}", + "text" : "", + "color" : "red" + } + ] + }""", + responseHandle: 'NONE', url: "${DOORAY_URL}", contentType: 'APPLICATION_JSON' + } + + }else { + manager.addShortText("good job") + + def messengerBody = "good job" + withCredentials([string(credentialsId: 'dooray_incoming_hookurl', variable: 'DOORAY_URL')]) { + + httpRequest httpMode: 'POST', + requestBody: """{"botName": "Jenkins Pipeline Training", "botIconImage": "https://static.dooray.com/static_images/dooray-bot.png", "text":"${messengerBody}", + "attachments" : [ + { + "title" : "jenkins", + "titleLink" : "${BUILD_URL}", + "text" : "", + "color" : "blue" + } + ] + }""", + responseHandle: 'NONE', url: "${DOORAY_URL}", contentType: 'APPLICATION_JSON' + } + } + } + + +} diff --git a/Jenkinsfile_declarative b/Jenkinsfile_declarative new file mode 100644 index 00000000..227596ad --- /dev/null +++ b/Jenkinsfile_declarative @@ -0,0 +1,26 @@ +pipeline { + agent any + tools { + maven 'mvn-3.6.0' + jdk 'openjdk11' + } + parameters { + string defaultValue: 'test', name: 'testType' + } + + + stages { + stage('build') { + steps { + sh "mvn clean ${params.testType}" + } + } + } + + post { + always { + junit 'target/surefire-reports/*.xml' + jacoco execPattern: 'target/**.exec' + } + } +} diff --git a/Jenkinsfile_caller b/Jenkinsfile_local_library similarity index 55% rename from Jenkinsfile_caller rename to Jenkinsfile_local_library index e61dc9f3..0db84053 100644 --- a/Jenkinsfile_caller +++ b/Jenkinsfile_local_library @@ -1,5 +1,5 @@ node('master') { checkout scm - def m = load('Jenkinsfile_module.groovy') + def m = load('mvn_build.groovy') m.mvnBuild("test") } diff --git a/Jenkinsfile_shared b/Jenkinsfile_shared index 16e6c0ea..7b80161d 100644 --- a/Jenkinsfile_shared +++ b/Jenkinsfile_shared @@ -1,4 +1,5 @@ @Library('demo')_ +// https://github.com/hyunil-shin/JenkinsPipelineTraining/blob/master/shared_library/shared/vars/mvn.groovy echo 'call library' mvn() diff --git a/Jenkinsfile_module.groovy b/mvn_build.groovy similarity index 82% rename from Jenkinsfile_module.groovy rename to mvn_build.groovy index 73735d26..26b3cd28 100644 --- a/Jenkinsfile_module.groovy +++ b/mvn_build.groovy @@ -2,7 +2,7 @@ def mvnBuild(testType) { stage('build') { - withEnv(["PATH+MAVEN=${tool 'mvn-3.6.0'}/bin"]) { + withEnv(["PATH+MAVEN=${tool 'mvn-3.8.6'}/bin"]) { sh 'mvn --version' sh "mvn clean ${testType}" }