-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
58 lines (56 loc) · 1.71 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
pipeline {
agent any
environment {
MAVEN_IMAGE = 'maven:3.6.1-jdk-8'
}
stages {
stage("Test") {
steps {
script {
docker.image(MAVEN_IMAGE).inside('-v /var/lib/jenkins/.m2:/root/.m2') {
sh 'mvn -v test'
}
}
}
}
stage("Publish image") {
options {
timeout(time: 1, unit: 'HOURS')
}
steps {
script {
sh 'mvn clean package dockerfile:build'
}
script {
docker.withRegistry('', 'dockerhub-credentials') {
docker.image("slonepi/reference-collector:${APP_VERSION}").push()
}
}
}
}
stage("Deploy Dev") {
when {
environment name: 'env', value: 'dev'
}
steps {
ansiblePlaybook( credentialsId: 'ssh_centos',
inventory: '~/ansible/build.yml',
playbook: 'ansible/playbook.yml',
extraVars: [ "DB_RECREATE": "${SHOULD_RESTART_DB}" ]
)
}
}
stage("Deploy Prod") {
when {
environment name: 'env', value: 'prod'
}
steps {
ansiblePlaybook( credentialsId: 'ssh_centos',
inventory: '~/ansible/prod.yml',
playbook: 'ansible/playbook.yml',
extraVars: [ "DB_RECREATE": "${SHOULD_RESTART_DB}" ]
)
}
}
}
}