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
93d23095c3
commit
b63e92337f
1 changed files with 7 additions and 13 deletions
20
Jenkinsfile
vendored
20
Jenkinsfile
vendored
|
@ -8,36 +8,30 @@ pipeline {
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage ('Checkstyle') {
|
stage ('Checkstyle') {
|
||||||
when { not { branch 'main' } }
|
|
||||||
steps {
|
steps {
|
||||||
sh 'mvn checkstyle:checkstyle'
|
sh 'mvn checkstyle:checkstyle'
|
||||||
archiveArtifacts artifacts: 'target/checkstyle-report.xml', allowEmptyArchive: true
|
archiveArtifacts artifacts: 'target/checkstyle-report.xml', allowEmptyArchive: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage ('Test') {
|
stage ('Test') {
|
||||||
when { not { branch 'main' } }
|
|
||||||
steps {
|
steps {
|
||||||
sh 'mvn test'
|
sh 'mvn test'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage ('Build') {
|
stage ('Build') {
|
||||||
when { not { branch 'main' } }
|
|
||||||
steps {
|
steps {
|
||||||
sh 'mvn clean package -DskipTests'
|
sh 'mvn clean package -DskipTests'
|
||||||
archiveArtifacts artifacts: 'target/*.jar', allowEmptyArchive: false
|
archiveArtifacts artifacts: 'target/*.jar', allowEmptyArchive: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage ('Creating Docker Image') {
|
stage ('Creating Docker image') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
sh 'docker build -t vkarpenko02/mr:${GIT_COMMIT} .'
|
||||||
def dockerRepo = branch == 'main' ? 'main' : 'mr'
|
withCredentials([usernamePassword(credentialsId: 'docker_key', usernameVariable: 'DOCKER_HUB_USER', passwordVariable: 'DOCKER_HUB_PASS')]) {
|
||||||
sh "docker build -t vkarpenko02/${dockerRepo}:${GIT_COMMIT} ."
|
sh """
|
||||||
withCredentials([usernamePassword(credentialsId: 'docker_key', usernameVariable: 'DOCKER_HUB_USER', passwordVariable: 'DOCKER_HUB_PASS')]) {
|
echo ${DOCKER_HUB_PASS} | docker login -u ${DOCKER_HUB_USER} --password-stdin
|
||||||
sh """
|
docker push vkarpenko02/mr:${GIT_COMMIT}
|
||||||
echo ${DOCKER_HUB_PASS} | docker login -u ${DOCKER_HUB_USER} --password-stdin
|
"""
|
||||||
docker push vkarpenko02/${dockerRepo}:${GIT_COMMIT}
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue