Update Jenkinsfile

This commit is contained in:
A-hash-bit 2022-08-11 16:21:48 +05:30 committed by GitHub
parent 456e9f760b
commit 3dcb7deb22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

58
Jenkinsfile vendored
View file

@ -1,46 +1,28 @@
pipeline{ node {
agent any def WORKSPACE = "/var/lib/jenkins/workspace/petclinic"
def dockerImageTag = "petclinic${env.BUILD_NUMBER}"
tools{ try{
maven "maven3" notifyBuild('STARTED')
} stage('Clone Repo') {
/* // for display purposes
triggers{ // Get some code from a GitHub repository
cron("* * * * *")
}
*/
stages{
stage("Checkout"){
steps{
echo "========executing checkout========"
git url:"https://github.com/A-hash-bit/spring-petclinic.git", branch:"main" git url:"https://github.com/A-hash-bit/spring-petclinic.git", branch:"main"
} }
stage('Build docker') {
dockerImage = docker.build("petclinic:${env.BUILD_NUMBER}")
} }
stage("Build"){ stage('Deploy docker'){
steps{ echo "Docker Image Tag Name: ${dockerImageTag}"
sh "mvn clean package" sh "docker stop petclinic || true && docker rm petclinic || true"
} sh "docker run --name petclinic -d -p 8081:8081 petclinic:${env.BUILD_NUMBER}"
}
stage('Docker Build') {
agent any
steps {
echo "========executing docker build========"
sh 'docker build -t amar/petclinic:latest .'
}
}
}
post{
always{
echo "========always========"
}
success{
echo "========pipeline executed successfully ========"
}
failure{
echo "========pipeline execution failed========"
} }
}catch(e){
currentBuild.result = "FAILED"
throw e
}finally{
notifyBuild(currentBuild.result)
} }
} }