mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 15:25: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'
|
DOCKER_CREDENTIALS_ID = 'dockerhub-credentials'
|
||||||
}
|
}
|
||||||
stages {
|
stages {
|
||||||
// stage('Checkstyle') {
|
stage('Checkstyle') {
|
||||||
// steps {
|
when {
|
||||||
// sh './mvnw checkstyle:checkstyle'
|
expression { env.BRANCH_NAME != 'main' }
|
||||||
// archiveArtifacts artifacts: 'target/checkstyle-result.xml', fingerprint: true
|
}
|
||||||
// }
|
steps {
|
||||||
// }
|
sh './mvnw checkstyle:checkstyle'
|
||||||
// stage('Test') {
|
archiveArtifacts artifacts: 'target/checkstyle-result.xml', fingerprint: true
|
||||||
// steps {
|
}
|
||||||
// sh './mvnw test'
|
}
|
||||||
// }
|
stage('Test') {
|
||||||
// }
|
when {
|
||||||
// stage('Build') {
|
expression { env.BRANCH_NAME != 'main' }
|
||||||
// steps {
|
}
|
||||||
// sh './mvnw clean package -DskipTests'
|
steps {
|
||||||
// }
|
sh './mvnw test'
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
|
stage('Build') {
|
||||||
|
when {
|
||||||
|
expression { env.BRANCH_NAME != 'main' }
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
sh './mvnw clean package -DskipTests'
|
||||||
|
}
|
||||||
|
}
|
||||||
stage('Create Docker Image') {
|
stage('Create Docker Image') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
withCredentials([usernamePassword(credentialsId: "${DOCKER_CREDENTIALS_ID}", usernameVariable: 'DOCKER_USERNAME', passwordVariable: 'DOCKER_PASSWORD')]) {
|
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 """
|
sh """
|
||||||
docker login -u \$DOCKER_USERNAME --password \$DOCKER_PASSWORD
|
docker login -u \$DOCKER_USERNAME --password \$DOCKER_PASSWORD
|
||||||
docker build -t marijastopa/mr-jenkins:blabla .
|
docker build -t marijastopa/${repoName}:${tag} .
|
||||||
docker push marijastopa/mr-jenkins:blabla
|
docker push marijastopa/${repoName}:${tag}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
echo "Pipeline execution completed."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue