-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
79 lines (75 loc) · 2.23 KB
/
Jenkinsfile
File metadata and controls
79 lines (75 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env groovy
import hudson.model.*
import hudson.EnvVars
import groovy.json.JsonSlurperClassic
import groovy.json.JsonBuilder
import groovy.json.JsonOutput
import java.net.URL
import org.jenkinsci.plugins.gitclient.Git;
import org.jenkinsci.plugins.gitclient.GitClient;
try {
node {
stage('Pre-Requirestion'){
properties([[$class: 'BuildDiscarderProperty',strategy: [$class: 'LogRotator', numToKeepStr: '5']],disableConcurrentBuilds(),])
echo("All environments=${env}")
echo("\u2600 BUILD_URL=${env.BUILD_URL}")
def workspace = pwd()
echo("\u2600 workspace=${workspace}")
mailnotification = "iamvj@gmail.com"
javaversion = 'JDK-1.8'
echo("\u2600 Java version=${javaversion}")
branchname = "${env.BRANCH_NAME}"
echo("\u2600 Branch Name=${branchname}")
sh ("git config --global user.email 'some@email.com'")
sh ("git config --global user.name 'jenkins'")
//def url = sh(returnStdout: true, script: 'git config remote.origin.url').trim()
//echo("url = ${url}")
//def mvnHome = tool 'M3'
//def javahome = tool 'openjdk'
}
stage('Checkout'){
echo "Git Checkout"
checkout scm
}
stage('Build'){
def mvnHome = tool 'M3'
def javahome = tool 'openjdk'
sh("${mvnHome}/bin/mvn clean install")
}
stage('SonarQube Ananlyis'){
echo "Hi Sonar"
withSonarQubeEnv('sonar'){
def mvnHome = tool 'M3'
sh("${mvnHome}/bin/mvn sonar:sonar")
}
}
stage('Docker Build'){
def mvnHome = tool 'M3'
sh("${mvnHome}/bin/mvn package")
}
stage('Publish Image'){
echo "Welclome Hub"
}
} // node
} // try end
catch (exc) {
/*
err = caughtError
currentBuild.result = "FAILURE"
String recipient = 'infra@lists.jenkins-ci.org'
mail subject: "${env.JOB_NAME} (${env.BUILD_NUMBER}) failed",
body: "It appears that ${env.BUILD_URL} is failing, somebody should do something about that",
to: recipient,
replyTo: recipient,
from: 'noreply@ci.jenkins.io'
*/
} finally {
(currentBuild.result != "ABORTED") && node("master") {
// Send e-mail notifications for failed or unstable builds.
// currentBuild.result must be non-null for this step to work.
//step([$class: 'Mailer',
// notifyEveryUnstableBuild: true,
// recipients: "${email_to}",
// sendToIndividuals: true])
}
}