mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 15:25:49 +00:00
Test changes to Jenkinsfile - merges two pipelines into one
This commit is contained in:
parent
ca0fe24df1
commit
ffd9a684bb
1 changed files with 29 additions and 43 deletions
72
Jenkinsfile
vendored
72
Jenkinsfile
vendored
|
@ -1,6 +1,7 @@
|
||||||
// Merge request pipeline
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
|
|
||||||
environment {
|
environment {
|
||||||
NEXUS_CREDS = credentials('nexus-cred')
|
NEXUS_CREDS = credentials('nexus-cred')
|
||||||
NEXUS_DOCKER_REPO_MR = '34.241.46.54:8085'
|
NEXUS_DOCKER_REPO_MR = '34.241.46.54:8085'
|
||||||
|
@ -11,6 +12,7 @@ pipeline {
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
|
// Merge request pipeline
|
||||||
stage('Checkstyle') {
|
stage('Checkstyle') {
|
||||||
steps{
|
steps{
|
||||||
echo 'Running gradle checkstyle'
|
echo 'Running gradle checkstyle'
|
||||||
|
@ -57,55 +59,39 @@ pipeline {
|
||||||
sh 'docker push $NEXUS_DOCKER_REPO_MR/spring-petclinic:${GIT_COMMIT}'
|
sh 'docker push $NEXUS_DOCKER_REPO_MR/spring-petclinic:${GIT_COMMIT}'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
post {
|
// Main branch pipeline
|
||||||
always {
|
|
||||||
cleanWs()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Main branch pipeline
|
|
||||||
pipeline {
|
|
||||||
agent any
|
|
||||||
|
|
||||||
environment {
|
|
||||||
NEXUS_CREDS = credentials('nexus-cred')
|
|
||||||
NEXUS_DOCKER_REPO_MAIN = '34.241.46.54:8084'
|
|
||||||
}
|
|
||||||
stages {
|
|
||||||
stage('Docker Build (Main)') {
|
stage('Docker Build (Main)') {
|
||||||
when {
|
when {
|
||||||
branch 'main'
|
branch 'main'
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
echo 'Building docker Image'
|
||||||
|
sh 'docker build -t $NEXUS_DOCKER_REPO_MAIN/spring-petclinic:${GIT_COMMIT} .'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
steps {
|
stage('Docker Login') {
|
||||||
echo 'Building docker Image'
|
when {
|
||||||
sh 'docker build -t $NEXUS_DOCKER_REPO_MAIN/spring-petclinic:${GIT_COMMIT} .'
|
branch 'main'
|
||||||
}
|
}
|
||||||
}
|
steps {
|
||||||
stage('Docker Login') {
|
echo 'Nexus Docker Repository Login'
|
||||||
when {
|
script{
|
||||||
branch 'main'
|
withCredentials([usernamePassword(credentialsId: 'nexus-cred', usernameVariable: 'USER', passwordVariable: 'PASS' )]){
|
||||||
}
|
sh 'echo $PASS | docker login -u $USER --password-stdin $NEXUS_DOCKER_REPO_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)') {
|
||||||
stage('Docker Push (Main)') {
|
when {
|
||||||
when {
|
branch 'main'
|
||||||
branch 'main'
|
}
|
||||||
|
steps {
|
||||||
|
echo 'Pushing Image to docker repo'
|
||||||
|
sh 'docker push $NEXUS_DOCKER_REPO_MAIN/spring-petclinic:${GIT_COMMIT}'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
steps {
|
|
||||||
echo 'Pushing Image to docker repo'
|
|
||||||
sh 'docker push $NEXUS_DOCKER_REPO_MAIN/spring-petclinic:${GIT_COMMIT}'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
always {
|
always {
|
||||||
|
|
Loading…
Reference in a new issue