-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
75 lines (63 loc) · 1.99 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
63
64
65
66
67
68
69
pipeline {
agent any
tools {
// Install the Maven version configured as "M3" and add it to the path.
maven 'M2_HOME'
jdk 'JAVA_HOME'
}
environment {
registry = "muckydreamz/tpachatdevops"
registryCredential = 'dockerhub'
NEXUS_VERSION = 'nexus3'
NEXUS_PROTOCOL = 'http'
NEXUS_URL = 'http://172.10.0.140:8081'
NEXUS_REPOSITORY = 'nexus-repo-devops'
NEXUS_CREDENDIAL_ID = 'nexus-user-credentials'
dockerImage = ''
}
stages {
stage('Checkout Git') {
steps {
echo 'Pulling ...';
git branch : 'master',
// Get some code from a GitHub repository
url: 'https://github.com/SyrineZahras/DevopsTPACHAT.git'
// Get System Current Date
script{
Date date = new Date()
String dateString = date.format("dd-MM-yyyy")
println "Date : " + dateString
}
mail body: 'Pipeline has been executed successfully', to: "ahlem.laajili@esprit.tn", subject: 'pipeline executed'
}
}
stage("Maven Build") {
steps {
script {
sh "mvn package -DskipTests=true"
}
}
}
stage('Building Docker image') {
steps {
script {
dockerImage = docker.build registry + ":$BUILD_NUMBER"
}
}
}
stage('Push Docker image') {
steps {
script {
docker.withRegistry( '', registryCredential ) {
dockerImage.push()
}
}
}
}
}
post {
failure {
mail body: 'Pipeline has failed', to: "syrine.zahras@esprit.tn", subject: 'Pipeline fail'
}
}
}