-
Notifications
You must be signed in to change notification settings - Fork 3
/
Jenkinsfile
56 lines (48 loc) · 1.51 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
def dockerFileContents = """
FROM centos:7
RUN yum update; yum clean all;
RUN yum -y install java-1.8.0-openjdk-devel.x86_64;
RUN yum -y install maven
RUN adduser jenkins
ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
""";
node {
def exception;
try {
stage("Checkout") {
checkout scm
}
stage('Prepare docker') {
fileOperations([fileCreateOperation(fileContent: "${dockerFileContents}", fileName: './Dockerfile')]);
}
def image = docker.build("project-cartographer-admin-server-image", "-f ./Dockerfile .");
image.inside('-u root') {
try {
stage('Build/Test') {
sh 'mvn -version'
sh 'mvn compile'
}
stage('Package') {
sh 'mvn package'
}
} finally {
def workspace = "${WORKSPACE}";
if (workspace) {
echo "workspace=${WORKSPACE}"
//we do this because of https://issues.jenkins-ci.org/browse/JENKINS-24440
//where if we run the container as root, but run docker as jenkins, then create files in the container
//as root, jenkins can't clean them up
sh "chmod -R 777 ${WORKSPACE}"
}
}
}
} catch (e) {
exception = e;
}
stage("Cleanup") {
deleteDir();
}
if (exception != null) {
throw exception;
}
}