mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 07:15:49 +00:00
Update Jenkinsfile
This commit is contained in:
parent
bf9c181775
commit
592b7338f9
1 changed files with 34 additions and 19 deletions
53
Jenkinsfile
vendored
53
Jenkinsfile
vendored
|
@ -4,35 +4,50 @@ pipeline {
|
|||
DOCKER_CREDENTIALS_ID = 'dockerhub-credentials'
|
||||
}
|
||||
stages {
|
||||
// stage('Checkstyle') {
|
||||
// steps {
|
||||
// sh './mvnw checkstyle:checkstyle'
|
||||
// archiveArtifacts artifacts: 'target/checkstyle-result.xml', fingerprint: true
|
||||
// }
|
||||
// }
|
||||
// stage('Test') {
|
||||
// steps {
|
||||
// sh './mvnw test'
|
||||
// }
|
||||
// }
|
||||
// stage('Build') {
|
||||
// steps {
|
||||
// sh './mvnw clean package -DskipTests'
|
||||
// }
|
||||
// }
|
||||
stage('Checkstyle') {
|
||||
when {
|
||||
expression { env.BRANCH_NAME != 'main' }
|
||||
}
|
||||
steps {
|
||||
sh './mvnw checkstyle:checkstyle'
|
||||
archiveArtifacts artifacts: 'target/checkstyle-result.xml', fingerprint: true
|
||||
}
|
||||
}
|
||||
stage('Test') {
|
||||
when {
|
||||
expression { env.BRANCH_NAME != 'main' }
|
||||
}
|
||||
steps {
|
||||
sh './mvnw test'
|
||||
}
|
||||
}
|
||||
stage('Build') {
|
||||
when {
|
||||
expression { env.BRANCH_NAME != 'main' }
|
||||
}
|
||||
steps {
|
||||
sh './mvnw clean package -DskipTests'
|
||||
}
|
||||
}
|
||||
stage('Create Docker Image') {
|
||||
steps {
|
||||
script {
|
||||
withCredentials([usernamePassword(credentialsId: "${DOCKER_CREDENTIALS_ID}", usernameVariable: 'DOCKER_USERNAME', passwordVariable: 'DOCKER_PASSWORD')]) {
|
||||
def repoName = env.BRANCH_NAME == 'main' ? 'main-jenkins' : 'mr-jenkins'
|
||||
def tag = env.GIT_COMMIT?.substring(0, 7) ?: 'latest'
|
||||
sh """
|
||||
docker login -u \$DOCKER_USERNAME --password \$DOCKER_PASSWORD
|
||||
docker build -t marijastopa/mr-jenkins:blabla .
|
||||
docker push marijastopa/mr-jenkins:blabla
|
||||
docker build -t marijastopa/${repoName}:${tag} .
|
||||
docker push marijastopa/${repoName}:${tag}
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
post {
|
||||
always {
|
||||
echo "Pipeline execution completed."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue