Repository navigation
Expand file tree
/
Copy pathJenkinsfile
More file actions
83 lines (77 loc) · 2.66 KB
/
Copy pathJenkinsfile
File metadata and controls
83 lines (77 loc) · 2.66 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
pipeline {
agent any
tools {
jdk 'jdk_25'
}
environment {
DOCKER_HUB_CREDENTIAL = credentials('dockerHub')
}
options {
timeout(time: 1, unit: 'HOURS')
disableConcurrentBuilds()
}
stages {
stage('Build tmail backend first') {
steps {
sh 'mkdir .build'
dir(".build") {
withCredentials([gitUsernamePassword(credentialsId: 'github')]) {
sh 'git clone https://github.com/linagora/tmail-backend.git'
}
dir("tmail-backend") {
sh 'git submodule init'
sh 'git submodule update'
sh 'mvn clean install -Dmaven.javadoc.skip=true -DskipTests -T1C'
}
}
}
}
stage('Compile') {
steps {
sh 'mvn clean install -Dmaven.javadoc.skip=true -DskipTests -T1C'
}
}
stage('Test') {
steps {
sh 'mvn -B surefire:test'
}
post {
always {
junit(testResults: '**/surefire-reports/*.xml', allowEmptyResults: false)
}
failure {
archiveArtifacts artifacts: '**/surefire-reports/*', fingerprint: true
}
}
}
stage('Deliver Docker image') {
when {
anyOf {
branch 'master'
buildingTag()
}
}
steps {
script {
env.DOCKER_TAG = 'branch-master'
if (env.TAG_NAME) {
env.DOCKER_TAG = env.TAG_NAME
}
echo "Docker tag: ${env.DOCKER_TAG}"
// Build the image from the Dockerfile using the artifacts produced
// by the Compile stage (multi-stage build copies them into the image;
// no Maven rebuild inside Docker). Replaces the former jib buildTar.
sh 'mvn -B dependency:copy-dependencies -DincludeScope=runtime -DoutputDirectory=target/dependency'
sh 'docker build --pull -t linagora/webadmin-proxy:$DOCKER_TAG -t linagora/webadmin-proxy:latest .'
sh 'echo $DOCKER_HUB_CREDENTIAL_PSW | docker login -u $DOCKER_HUB_CREDENTIAL_USR --password-stdin'
sh 'docker push linagora/webadmin-proxy:$DOCKER_TAG'
}
}
}
}
post {
always {
deleteDir()
}
}
}