-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
executable file
·50 lines (50 loc) · 1.3 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
def label = "buildpod.${env.JOB_NAME}.${env.BUILD_NUMBER}".replace('-', '_').replace('/', '_')
podTemplate(label: label, containers: [
containerTemplate(
name: 'maven',
image: 'maven:3.6.2-jdk-8',
command: 'cat',
ttyEnabled: true
),
containerTemplate(
name: 'docker',
image: 'docker',
command: 'cat',
ttyEnabled: true
)
],
volumes: [
hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock')
]) {
node(label) {
def myRepo = checkout scm
stage('Test') {
try {
container('maven') {
sh """mvn test"""
}
}
catch (exc) {
println "Failed to test - ${currentBuild.fullDisplayName}"
}
}
stage('Build') {
try {
container('maven') {
sh """mvn clean package"""
}
}
catch (exc) {
println "Failed to build - ${currentBuild.fullDisplayName}"
}
}
stage('Create Docker images') {
container('docker') {
def image = docker.build("806950227484.dkr.ecr.eu-central-1.amazonaws.com/hello:b-${BUILD_NUMBER}")
docker.withRegistry('https://806950227484.dkr.ecr.eu-central-1.amazonaws.com', 'ecr:eu-central-1:terraform_role') {
image.push()
}
}
}
}
}