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

84 changes: 56 additions & 28 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,40 +1,68 @@
pipeline{

agent any
pipeline {
agent none
stages {
stage('build') {
agent {
docker {
image 'schoolofdevops/carts-maven'
}

// uncomment the following lines by removing /* and */ to enable
tools{
maven 'Maven 3.6.3'
}
steps {
echo 'this is the build job'
sh 'mvn compile'
}
}


stages{
stage('build'){
steps{
echo 'this is the build job'
sh 'mvn compile'
}
stage('test') {
agent {
docker {
image 'schoolofdevops/carts-maven'
}
stage('test'){
steps{
echo 'this is the test job'
sh 'mvn clean test'
}
}
stage('package'){
steps{
echo 'this is the package job'
sh 'mvn package -DskipTests'
}

}
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'
}
}

post{
always{
echo 'this pipeline has completed...'
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...'
}

}
}