Update Jenkinsfile

This commit is contained in:
Mihai Georgescu 2023-11-28 09:48:19 +02:00 committed by GitHub
parent 85af366590
commit 354238948d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

22
Jenkinsfile vendored
View file

@ -4,7 +4,7 @@ pipeline {
stage('Checkstyle') {
steps {
sh 'mvn checkstyle:checkstyle'
archiveArtifacts artifacts: 'checkstyle-result.html', onlyIfSuccessful: true
archiveArtifacts artifacts: 'target/checkstyle-result.html', onlyIfSuccessful: true
}
}
stage('Tests') {
@ -16,18 +16,34 @@ pipeline {
stage('Build') {
steps {
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') {
steps {
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') {
steps {
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') {