Latest Jenkinsfile

This commit is contained in:
Lihan 2024-07-27 01:45:58 -04:00
parent c744a71a5f
commit 812ec78b69

13
Jenkinsfile vendored
View file

@ -4,12 +4,13 @@ pipeline {
environment { environment {
SONARQUBE_URL = 'http://sonarqube:9000' SONARQUBE_URL = 'http://sonarqube:9000'
SONARQUBE_CREDENTIALS_ID = 'admin' SONARQUBE_CREDENTIALS_ID = 'admin'
GITHUB_TOKEN = credentials('github-token')
} }
stages { stages {
stage('Checkout') { stage('Checkout') {
steps { steps {
checkout scm git url: 'https://github.com/CChariot/spring-petclinic.git', branch: 'FinalProject_main', credentialsId: 'github-token'
} }
} }
@ -46,7 +47,9 @@ pipeline {
stage('Run Application') { stage('Run Application') {
steps { steps {
script { script {
dockerImage.run("-p 8080:8080 --name spring-petclinic") dockerImage.inside("-u root") {
sh 'java -jar target/*.jar'
}
} }
} }
} }
@ -77,8 +80,10 @@ pipeline {
post { post {
always { always {
script { script {
dockerImage.stop() if (dockerImage != null) {
dockerImage.remove() dockerImage.stop()
dockerImage.remove()
}
} }
} }
success { success {