mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2026-02-11 17:01:11 +00:00
Update Jenkinsfile.pr
Signed-off-by: Riz Urian <98958099+rizjosel@users.noreply.github.com>
This commit is contained in:
parent
6643a49a9f
commit
76cd447401
1 changed files with 7 additions and 37 deletions
|
|
@ -8,18 +8,11 @@ pipeline {
|
|||
IMAGE_NAME = "${DOCKER_USER}/${APP_NAME}:${IMAGE_TAG}"
|
||||
}
|
||||
|
||||
triggers {
|
||||
// Triggered by GitHub Pull Requests
|
||||
githubPullRequest()
|
||||
}
|
||||
|
||||
stages {
|
||||
|
||||
stage('Notify GitHub Pending') {
|
||||
steps {
|
||||
script {
|
||||
githubNotify context: 'Jenkins CI', status: 'PENDING'
|
||||
}
|
||||
githubNotify context: 'Jenkins CI', status: 'PENDING'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -31,27 +24,14 @@ pipeline {
|
|||
|
||||
stage('CI / Unit Tests') {
|
||||
steps {
|
||||
script {
|
||||
try {
|
||||
// Run Gradle unit tests
|
||||
sh './gradlew clean build -x test'
|
||||
junit 'build/test-results/test/*.xml'
|
||||
} catch (err) {
|
||||
error "Unit tests failed!"
|
||||
}
|
||||
}
|
||||
sh './gradlew clean build -x test'
|
||||
junit 'build/test-results/test/*.xml'
|
||||
}
|
||||
}
|
||||
|
||||
stage('CI / Docker Build') {
|
||||
steps {
|
||||
script {
|
||||
try {
|
||||
sh "docker build -t ${IMAGE_NAME} ."
|
||||
} catch (err) {
|
||||
error "Docker build failed!"
|
||||
}
|
||||
}
|
||||
sh "docker build -t ${IMAGE_NAME} ."
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -59,16 +39,10 @@ pipeline {
|
|||
steps {
|
||||
script {
|
||||
try {
|
||||
// Start Docker container
|
||||
sh "docker run -d --name ${APP_NAME}-test -p 8080:8080 ${IMAGE_NAME}"
|
||||
sh "sleep 15" // wait for app to start
|
||||
|
||||
// Health check
|
||||
sh "sleep 15"
|
||||
sh "curl -f http://localhost:8080/actuator/health"
|
||||
} catch (err) {
|
||||
error "Docker integration tests failed!"
|
||||
} finally {
|
||||
// Clean up container
|
||||
sh "docker stop ${APP_NAME}-test || true"
|
||||
sh "docker rm ${APP_NAME}-test || true"
|
||||
}
|
||||
|
|
@ -79,14 +53,10 @@ pipeline {
|
|||
|
||||
post {
|
||||
success {
|
||||
script {
|
||||
githubNotify context: 'Jenkins CI', status: 'SUCCESS'
|
||||
}
|
||||
githubNotify context: 'Jenkins CI', status: 'SUCCESS'
|
||||
}
|
||||
failure {
|
||||
script {
|
||||
githubNotify context: 'Jenkins CI', status: 'FAILURE'
|
||||
}
|
||||
githubNotify context: 'Jenkins CI', status: 'FAILURE'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue