-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
88 lines (79 loc) · 2.36 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
pipeline {
agent any
tools{
maven 'M2_HOME'
jdk 'JAVA_HOME'
}
environment {
SONAR_TOKEN = credentials('sonar-token')
registry = "auckfmine/devops"
registryCredential = 'dockerhub_id'
dockerImage = ''
}
stages{
stage('print sonar token'){
steps{
echo '$SONAR_TOKEN';
}
}
stage('Chekout GIT'){
steps{
echo 'Pulling...';
git branch: 'master' ,
url : 'https://github.com/Auckfmine/Project-Management-System.git'
}
}
stage('cleaning java Project'){
steps{
sh 'mvn clean'
}
}
stage('compiling java Project'){
steps{
sh 'mvn compile'
}
}
stage("build & SonarQube analysis") {
steps {
sh 'mvn sonar:sonar -Dsonar.host.url=http://172.10.0.140:9000 -Dsonar.login=$SONAR_TOKEN'
}
}
stage('build artifact'){
steps{
sh 'mvn package'
}
}
stage('deploy jar to nexus'){
steps{
sh 'mvn deploy:deploy-file -DgroupId=com.esprit.examen \
-DartifactId=tpAchatProject \
-Dversion=1.0 \
-Dpackaging=jar \
-Dfile=./target/tpAchatProject-1.0.jar \
-DrepositoryId=esprit-devops \
-Durl=http://172.10.0.140:8081/repository/esprit-devops/'
}
}
stage('Building our image') {
steps {
script {
dockerImage = docker.build registry + ":$BUILD_NUMBER"
}
}
}
stage('Deploy our image') {
steps {
script {
docker.withRegistry( '', registryCredential ) {
dockerImage.push()
}
}
}
}
stage('Cleaning up') {
steps {
sh "docker rmi $registry:$BUILD_NUMBER"
}
}
}
}