mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-23 08:15:49 +00:00
Update Jenkinsfile
This commit is contained in:
parent
85af366590
commit
354238948d
1 changed files with 19 additions and 3 deletions
22
Jenkinsfile
vendored
22
Jenkinsfile
vendored
|
@ -4,7 +4,7 @@ pipeline {
|
||||||
stage('Checkstyle') {
|
stage('Checkstyle') {
|
||||||
steps {
|
steps {
|
||||||
sh 'mvn checkstyle:checkstyle'
|
sh 'mvn checkstyle:checkstyle'
|
||||||
archiveArtifacts artifacts: 'checkstyle-result.html', onlyIfSuccessful: true
|
archiveArtifacts artifacts: 'target/checkstyle-result.html', onlyIfSuccessful: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Tests') {
|
stage('Tests') {
|
||||||
|
@ -16,18 +16,34 @@ pipeline {
|
||||||
stage('Build') {
|
stage('Build') {
|
||||||
steps {
|
steps {
|
||||||
echo "now we will begin the build"
|
echo "now we will begin the build"
|
||||||
sh 'mvn clean package -DskipTests'
|
script {
|
||||||
|
def appBuildoutPut = sh (script: 'mvn clean package -Dskiptests')
|
||||||
|
if (appBuildoutPut == 0) {
|
||||||
|
echo "build SUCCESSFUL"
|
||||||
|
} else {
|
||||||
|
error "Build failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Create docker image') {
|
stage('Create docker image') {
|
||||||
steps {
|
steps {
|
||||||
echo "now we will begin the creation of the docker image"
|
echo "now we will begin the creation of the docker image"
|
||||||
sh "docker build -t imagine_spring_petclinic:0.1 ."
|
script {
|
||||||
|
def dockerBuildOutput = sh(script: 'docker build -t imagine_spring_petclinic:0.1 .', returnStatus: true)
|
||||||
|
if (dockerBuildOutput == 0) {
|
||||||
|
echo "Build successful"
|
||||||
|
} else {
|
||||||
|
error "Build failed" // Optional: Terminate the pipeline with an error message if the build fails
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Tag the docker image') {
|
stage('Tag the docker image') {
|
||||||
steps {
|
steps {
|
||||||
echo "now we will tag the docker image"
|
echo "now we will tag the docker image"
|
||||||
|
def dockerTag = sh(returnStdout: true, script: 'git rev-parse --short HEAD').trim()
|
||||||
|
echo "The tag used for Docker image: ${dockerTag}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Push to DockerHub') {
|
stage('Push to DockerHub') {
|
||||||
|
|
Loading…
Reference in a new issue