new commit4

This commit is contained in:
Botoi Adrian 2024-11-22 12:43:43 +02:00
parent 821eaf4580
commit 4f2202e60e

52
Jenkinsfile vendored Normal file
View file

@ -0,0 +1,52 @@
pipeline {
agent any
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Checkstyle') {
steps {
script {
sh './gradlew checkstyleMain'
}
}
post {
success {
archiveArtifacts artifacts: 'build/reports/checkstyle/*.xml', allowEmptyArchive: true
}
}
}
stage('Unit Tests') {
steps {
script {
echo "Running unit tests..."
sh './gradlew test'
}
}
}
stage('Build without Tests') {
steps {
script {
sh './gradlew build -x test'
}
}
}
stage('Create Docker Image - MR') {
when {
branch 'PR-*' // This will trigger for pull requests (merge requests)
}
steps {
script {
// Build Docker image with the short Git commit hash as the tag
def gitCommit = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
sh "docker build -t ${DOCKER_REGISTRY}/mr/spring-petclinic:${gitCommit} ."
sh "docker login -u ${DOCKER_CREDENTIALS_USR} -p ${DOCKER_CREDENTIALS_PSW}"
sh "docker push ${DOCKER_REGISTRY}/mr/spring-petclinic:${gitCommit}"
}
}
}
}
}