-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
46 lines (41 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
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("sarataha/docker-jenkins-java-pipeline:${env.BUILD_NUMBER}").push()
docker.build("sarataha/docker-jenkins-java-pipeline:${env.BUILD_NUMBER}")
}
}
stage ('Run Application') {
try {
// sh 'docker run -d --name db -p 8091-8093:8091-8093 -p 11210:11210 sarataha/oreilly-couchbase:latest'
sh "docker run -e DB_URI=`docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' db` sarataha/docker-jenkins-java-pipeline:${env.BUILD_NUMBER}"
//dir ('webapp') {
// sh 'mvn exec:java -DskipTests'
//}
} catch (error) {
} finally {
//sh 'docker-compose stop db'
//sh 'docker-compose rm db'
}
}
stage('Run Tests') {
try {
//db = docker.image("sarataha/couchbase").withRun("-d --name db --service-ports db")
dir('webapp') {
//sh "mvn test -DDB_URI=`docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' db`"
sh "mvn test"
}
} catch (error) {
} finally {
//db.stop()
junit '**/target/surefire-reports/*.xml'
}
}
}