forked from sathishbob/jenkins_test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
62 lines (56 loc) · 2.18 KB
/
Jenkinsfile
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
properties([pipelineTriggers([githubPush()])])
pipeline {
agent any
tools {
// Install the Maven version configured as "M3" and add it to the path.
maven "MVN3"
}
stages {
stage("print1") {
steps {
echo "printing 1"
}
}
stage("print2") {
steps {
echo "printing 2"
}
}
stage('Build') {
agent {
label 'linux'
}
steps {
// Get some code from a GitHub repository
git credentialsId: 'github', url: '[email protected]:sathishbob/jenkins_test.git'
// Run Maven on a Unix agent.
sh "mvn -Dmaven.test.failure.ignore=true -f api-gateway clean package"
// To run Maven on a Windows agent, use
// bat "mvn -Dmaven.test.failure.ignore=true clean package"
}
post {
// If Maven was able to run the tests, even if some of the test
// failed, record the test results and archive the jar file.
success {
junit 'api-gateway/target/surefire-reports/*.xml'
archiveArtifacts 'api-gateway/target/*.jar'
emailext body: "Please check the console output at $BUILD_URL for more information", to: "[email protected]", subject: '$PROJECT_NAME is completed - Build number is $BUILD_NUMBER - Build status is $BUILD_STATUS'
}
}
}
stage("Email") {
steps {
script {
cest = TimeZone.getTimeZone("CEST")
def cest = new Date ()
println(cest)
def mailRecipients = '[email protected]'
def jobName = currentBuild.fullDisplayName
env.Name = Name
env.cest = cest
emailext body: '''${SCRIPT, template="email-html.template"}''', mimeType: 'text/html', subject: "[jenkins] ${jobName}", to: "${mailRecipients}", replyTo: "${mailRecipients}"
}
}
}
}
}