mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 15:25:49 +00:00
Second pipeline for main branch
This commit is contained in:
parent
ebfebd789d
commit
a005cf06ca
1 changed files with 50 additions and 4 deletions
54
Jenkinsfile
vendored
54
Jenkinsfile
vendored
|
@ -4,7 +4,6 @@ pipeline {
|
|||
environment {
|
||||
NEXUS_CREDS = credentials('nexus-cred')
|
||||
NEXUS_DOCKER_REPO_MR = '34.241.46.54:8085'
|
||||
NEXUS_DOCKER_REPO_MAIN = '34.241.46.54:8084'
|
||||
}
|
||||
|
||||
tools {
|
||||
|
@ -35,8 +34,7 @@ pipeline {
|
|||
sh './gradlew build -x test -x check -x checkFormat -x processTestAot --no-daemon'
|
||||
archiveArtifacts artifacts: 'build/libs/*.jar', fingerprint: true }
|
||||
}
|
||||
stage('Docker Build') {
|
||||
|
||||
stage('Docker Build (MR)') {
|
||||
steps {
|
||||
echo 'Building docker Image'
|
||||
sh 'docker build -t $NEXUS_DOCKER_REPO_MR/spring-petclinic:${GIT_COMMIT} .'
|
||||
|
@ -53,7 +51,7 @@ pipeline {
|
|||
}
|
||||
}
|
||||
}
|
||||
stage('Docker Push') {
|
||||
stage('Docker Push (MR)') {
|
||||
steps {
|
||||
echo 'Pushing Image to docker hub'
|
||||
sh 'docker push $NEXUS_DOCKER_REPO_MR/spring-petclinic:${GIT_COMMIT}'
|
||||
|
@ -61,6 +59,54 @@ pipeline {
|
|||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
cleanWs()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Main branch pipeline
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
environment {
|
||||
NEXUS_CREDS = credentials('nexus-cred')
|
||||
NEXUS_DOCKER_REPO_MAIN = '34.241.46.54:8084'
|
||||
}
|
||||
|
||||
stage('Docker Build (Main)') {
|
||||
when {
|
||||
branch 'main'
|
||||
}
|
||||
steps {
|
||||
echo 'Building docker Image'
|
||||
sh 'docker build -t $NEXUS_DOCKER_REPO_MAIN/spring-petclinic:${GIT_COMMIT} .'
|
||||
}
|
||||
}
|
||||
stage('Docker Login') {
|
||||
when {
|
||||
branch 'main'
|
||||
}
|
||||
steps {
|
||||
echo 'Nexus Docker Repository Login'
|
||||
script{
|
||||
withCredentials([usernamePassword(credentialsId: 'nexus-cred', usernameVariable: 'USER', passwordVariable: 'PASS' )]){
|
||||
sh 'echo $PASS | docker login -u $USER --password-stdin $NEXUS_DOCKER_REPO_MAIN'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Docker Push (Main)') {
|
||||
when {
|
||||
branch 'main'
|
||||
}
|
||||
steps {
|
||||
echo 'Pushing Image to docker hub'
|
||||
sh 'docker push $NEXUS_DOCKER_REPO_MAIN/spring-petclinic:${GIT_COMMIT}'
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
cleanWs()
|
||||
|
|
Loading…
Reference in a new issue