-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
49 lines (43 loc) · 1.24 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
node {
checkout scm
env.PATH = "${tool 'Maven3'}/bin:${env.PATH}"
stage('Package') {
dir('webapp') {
sh 'mvn clean package -DskipTests'
}
}
stage('Create Docker Image') {
dir('webapp') {
docker.build("arungupta/docker-jenkins-pipeline:${env.BUILD_NUMBER}")
}
}
stage ('Run Application') {
try {
// Start database container here
// sh 'docker run -d --name db -p 8091-8093:8091-8093 -p 11210:11210 arungupta/oreilly-couchbase:latest'
// Run application using Docker image
sh "DB=`docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' db`"
sh "docker run -e DB_URI=$DB arungupta/docker-jenkins-pipeline:${env.BUILD_NUMBER}"
// Run tests using Maven
//dir ('webapp') {
// sh 'mvn exec:java -DskipTests'
//}
} catch (error) {
} finally {
// Stop and remove database container here
//sh 'docker-compose stop db'
//sh 'docker-compose rm db'
}
}
stage('Run Tests') {
try {
dir('webapp') {
sh "mvn test"
docker.build("arungupta/docker-jenkins-pipeline:${env.BUILD_NUMBER}").push()
}
} catch (error) {
} finally {
junit '**/target/surefire-reports/*.xml'
}
}
}