Update Jenkinsfile

This commit is contained in:
A-hash-bit 2022-08-16 09:32:58 +05:30 committed by GitHub
parent 22642a7137
commit cdd84ac588
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

55
Jenkinsfile vendored
View file

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