Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM schoolofdevops/carts-maven


WORKDIR /opt/carts

COPY . .

RUN mvn package \
&& mv target/carts.jar /run \
&& rm -rf *

EXPOSE 80

CMD java -jar /run/carts.jar --port=80

68 changes: 68 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
pipeline {
agent none
stages {
stage('build') {
agent {
docker {
image 'schoolofdevops/carts-maven'
}

}
steps {
echo 'this is the build job'
sh 'mvn compile'
}
}

stage('test') {
agent {
docker {
image 'schoolofdevops/carts-maven'
}

}
steps {
echo 'this is the test job'
sh 'mvn clean test'
}
}

stage('package') {
agent {
docker {
image 'schoolofdevops/carts-maven'
}

}
steps {
echo 'this is the package job'
sh 'mvn package -DskipTests'
archiveArtifacts '**/target/*.jar'
}
}

stage('docker build and publish') {
agent any
steps {
script {
docker.withRegistry('https://index.docker.io/v1/', 'dockerlogin') {
def dockerImage = docker.build("prat91/carts:v${env.BUILD_ID}", "./")
dockerImage.push()
dockerImage.push("latest")
}
}

}
}

}
tools {
maven 'Maven 3.6.3'
}
post {
always {
echo 'this pipeline has completed...'
}

}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<version>2.20</version>
<configuration>
<includes>
<include>**/Unit*.java</include>
Expand Down