Permalink
Switch branches/tags
Nothing to show
Find file Copy path
10a4ce7 Sep 9, 2016
2 contributors

Users who have contributed to this file

@arun-gupta @lordofthejars
50 lines (43 sloc) 1.24 KB
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'
}
}
}