forked from brahimakh/simple-java-hello-world
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
92 lines (80 loc) · 1.38 KB
/
Jenkinsfile
File metadata and controls
92 lines (80 loc) · 1.38 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
80
81
82
83
84
85
86
87
88
89
90
91
92
// Configuration des images docker utilisées pour les différentes étapes CI/CD
pipeline {
agent {
kubernetes {
label 'mypod'
defaultContainer 'jnlp'
yaml """
apiVersion: v1
kind: Pod
metadata:
labels:
some-label: some-label-value
spec:
containers:
- name: maven
image: maven:alpine
command:
- cat
tty: true
- name: docker
image: docker
command:
- cat
tty: true
volumeMounts:
- name: dockersock
mountPath: /var/run/docker.sock
volumes:
- name: dockersock
hostPath:
path: /var/run/docker.sock
"""
}
}
// Configuration à modifier
stages {
stage('Build') {
steps {
container('maven') {
sh 'mvn -B -DskipTests clean package'
}
}
}
stage('Test'){
steps{
container('maven'){
sh 'mvn test'
}
}
}
stage('Docker Build'){
when {
anyOf {
branch 'master';
branch 'develop'
}
}
steps{
container('docker'){
sh 'docker build -t my-app:$BUILD_NUMBER .'
}
}
}
stage('Docker run'){
when {
branch 'master';
}
steps{
container('docker'){
sh 'docker run my-app:$BUILD_NUMBER'
}
}
}
}
post {
always {
junit 'target/surefire-reports/*.xml'
}
}
}