forked from Epitech/epitest-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
105 lines (100 loc) · 3.61 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!groovy
pipeline {
agent {
label 'docker'
}
options {
buildDiscarder(logRotator(daysToKeepStr:'15'))
}
parameters {
string(name: 'epitest_docker_tag', description: 'Tag of the epitest-docker image', defaultValue: 'devel')
booleanParam(name: 'RELEASE', description: 'Release this docker image (epitest_docker_tag will be ignored and replaces by latest', defaultValue: false)
}
stages {
stage('Build') {
when {
not {
expression {
return params.RELEASE
}
}
}
steps {
ansiColor('xterm') {
sh "./build.sh --tag ${params.epitest_docker_tag} "
}
}
}
stage('Build Release') {
when {
expression {
return params.RELEASE
}
}
steps {
ansiColor('xterm') {
sh "./build.sh --tag latest"
}
}
}
stage('Archive') {
when {
not {
expression {
return params.RELEASE
}
}
}
steps {
ansiColor('xterm') {
script {
docker.withRegistry('https://nexus.epitest.eu:9081/', 'nexus-epitest-ci') {
sh "docker tag epitechcontent/epitest-docker:${params.epitest_docker_tag} nexus.epitest.eu:9081/epitechcontent/epitest-docker:${params.epitest_docker_tag} && docker push nexus.epitest.eu:9081/epitechcontent/epitest-docker:${params.epitest_docker_tag}"
}
docker.withRegistry('https://index.docker.io/v1/', 'dockerhub-login') {
sh "docker push epitechcontent/epitest-docker:${params.epitest_docker_tag}"
}
}
}
}
}
stage('Release') {
when {
expression {
return params.RELEASE
}
}
steps {
ansiColor('xterm') {
script {
docker.withRegistry('https://nexus.epitest.eu:9081/', 'nexus-epitest-ci') {
sh "docker tag epitechcontent/epitest-docker:latest nexus.epitest.eu:9081/epitechcontent/epitest-docker:latest && docker push nexus.epitest.eu:9081/epitechcontent/epitest-docker:latest"
}
docker.withRegistry('https://index.docker.io/v1/', 'dockerhub-login') {
sh "docker push epitechcontent/epitest-docker:latest"
}
}
}
}
}
}
post {
success {
withCredentials([string(credentialsId: 'teams-webhook', variable: 'TEAMS_WEBHOOK')]) {
script {
office365ConnectorSend message: "Build Success for $JOB_NAME#$BUILD_ID", status:"Success", webhookUrl:"$TEAMS_WEBHOOK"
}
}
}
failure {
withCredentials([string(credentialsId: 'teams-webhook', variable: 'TEAMS_WEBHOOK')]) {
script {
office365ConnectorSend message: "Build Failure for $JOB_NAME#$BUILD_ID", status:"Failure", webhookUrl:"$TEAMS_WEBHOOK"
}
}
}
always {
deleteDir()
}
}
}