mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 06:45:50 +00:00
Edit Jenkinsfile
This commit is contained in:
parent
bc7b67fdae
commit
dc0ea24d45
1 changed files with 8 additions and 2 deletions
10
Jenkinsfile
vendored
10
Jenkinsfile
vendored
|
@ -4,7 +4,7 @@ pipeline {
|
||||||
environment {
|
environment {
|
||||||
GIT_COMMIT = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
|
GIT_COMMIT = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
|
||||||
DOCKER_CREDS = credentials('docker_key')
|
DOCKER_CREDS = credentials('docker_key')
|
||||||
DOCKER_REPO = ''
|
DOCKER_REPO = '' // Default empty
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
|
@ -17,11 +17,12 @@ pipeline {
|
||||||
DOCKER_REPO = 'vkarpenko02/mr'
|
DOCKER_REPO = 'vkarpenko02/mr'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
echo "Docker repository set to: ${DOCKER_REPO}" // Debugging step
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Checkstyle') {
|
stage('Checkstyle') {
|
||||||
when { not { branch 'main' } } // Only for MR pipelines
|
when { not { branch 'main' } }
|
||||||
steps {
|
steps {
|
||||||
sh 'mvn checkstyle:checkstyle'
|
sh 'mvn checkstyle:checkstyle'
|
||||||
archiveArtifacts artifacts: 'target/site/checkstyle.html', allowEmptyArchive: true
|
archiveArtifacts artifacts: 'target/site/checkstyle.html', allowEmptyArchive: true
|
||||||
|
@ -43,6 +44,11 @@ pipeline {
|
||||||
|
|
||||||
stage('Create Docker Image') {
|
stage('Create Docker Image') {
|
||||||
steps {
|
steps {
|
||||||
|
script {
|
||||||
|
if (!DOCKER_REPO) {
|
||||||
|
error "DOCKER_REPO is not set. Ensure the repository is configured for the current branch."
|
||||||
|
}
|
||||||
|
}
|
||||||
sh 'docker build -t ${DOCKER_REPO}:${GIT_COMMIT} .'
|
sh 'docker build -t ${DOCKER_REPO}:${GIT_COMMIT} .'
|
||||||
withCredentials([usernamePassword(credentialsId: 'docker_key', usernameVariable: 'DOCKER_HUB_USER', passwordVariable: 'DOCKER_HUB_PASS')]) {
|
withCredentials([usernamePassword(credentialsId: 'docker_key', usernameVariable: 'DOCKER_HUB_USER', passwordVariable: 'DOCKER_HUB_PASS')]) {
|
||||||
sh """
|
sh """
|
||||||
|
|
Loading…
Reference in a new issue