mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 07:15:49 +00:00
jenkins pipelines updated
This commit is contained in:
parent
6218422a62
commit
44cc836418
4 changed files with 19 additions and 10 deletions
|
@ -1,5 +1,7 @@
|
|||
pipeline {
|
||||
agent any
|
||||
agent {
|
||||
label 'agent1'
|
||||
}
|
||||
triggers {
|
||||
pollSCM('H/5 * * * *') // Watches the `dev` branch
|
||||
}
|
||||
|
@ -7,7 +9,6 @@ pipeline {
|
|||
DOCKERHUB_CREDENTIALS = credentials('nalexx6_docker_pass')
|
||||
DOCKERHUB_USERNAME = "nalexx6"
|
||||
NEXUS_SNAPHOT_URL = 'http://localhost:8081/repository/maven-snapshots'
|
||||
def ARTIFACT_VERSION = sh(script: "mvn help:evaluate -Dexpression=project.version -q -DforceStdout", returnStdout: true).trim()
|
||||
ARTIFACT_PATH = "target"
|
||||
|
||||
}
|
||||
|
@ -25,14 +26,16 @@ pipeline {
|
|||
}
|
||||
stage('Upload to Nexus') {
|
||||
steps {
|
||||
sh """
|
||||
mvn deploy:deploy-file -DgroupId=org -DartifactId=petclinic -Dversion=${ARTIFACT_VERSION} -Dpackaging=jar -Dfile=./target/petclinic-${ARTIFACT_VERSION}.jar -DrepositoryId=maven-snapshots -Durl=${NEXUS_SNAPHOT_URL} --settings settings.xml
|
||||
"""
|
||||
script {
|
||||
def ARTIFACT_VERSION = sh(script: "./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout", returnStdout: true).trim()
|
||||
sh """./mvnw deploy:deploy-file -DgroupId=org -DartifactId=petclinic -Dversion=${ARTIFACT_VERSION} -Dpackaging=jar -Dfile=./target/petclinic-${ARTIFACT_VERSION}.jar -DrepositoryId=maven-snapshots -Durl=${NEXUS_SNAPHOT_URL} --settings settings.xml"""
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Build Docker Image') {
|
||||
steps {
|
||||
script {
|
||||
def ARTIFACT_VERSION = sh(script: "./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout", returnStdout: true).trim()
|
||||
sh "DOCKER_BUILDKIT=0 docker build --build-arg ARTIFACT_VERSION=${ARTIFACT_VERSION} --build-arg ARTIFACT_PATH=${ARTIFACT_PATH} -t petclinic:${ARTIFACT_VERSION} ."
|
||||
sh "docker tag petclinic:${ARTIFACT_VERSION} ${DOCKERHUB_USERNAME}/petclinic:${ARTIFACT_VERSION}"
|
||||
sh "docker login -u ${DOCKERHUB_USERNAME} -p ${DOCKERHUB_CREDENTIALS}"
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
pipeline {
|
||||
agent any
|
||||
agent {
|
||||
label 'agent1'
|
||||
}
|
||||
parameters {
|
||||
string(name: 'ARTIFACT_VERSION', description: 'Version of the artifact to deploy')
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
pipeline {
|
||||
agent any
|
||||
agent {
|
||||
label 'agent1'
|
||||
}
|
||||
triggers {
|
||||
pollSCM('H/5 * * * *') // Adjust polling interval as needed
|
||||
}
|
||||
stages {
|
||||
stage('Checkout Code') {
|
||||
steps {
|
||||
git url: 'https://github.com/spring-projects/spring-petclinic.git', branch: 'main'
|
||||
git url: 'https://github.com/Nalexx06/spring-petclinic.git', branch: 'dev'
|
||||
}
|
||||
}
|
||||
stage('Build & Test') {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
pipeline {
|
||||
agent any
|
||||
agent {
|
||||
label 'agent1'
|
||||
}
|
||||
parameters {
|
||||
string(name: 'SNAPSHOT_VERSION', description: 'Snapshot version to promote')
|
||||
}
|
||||
|
@ -26,7 +28,7 @@ pipeline {
|
|||
stage('Promote Artifact to Release') {
|
||||
steps {
|
||||
script {
|
||||
sh "mvn deploy:deploy-file -DgroupId=org -DartifactId=petclinic -Dversion=${RELEASE_VERSION} -Dpackaging=jar -Dfile=petclinic-${RELEASE_VERSION}.jar -DrepositoryId=maven-releases -Durl=${NEXUS_RELEASE_URL} --settings settings.xml"
|
||||
sh "./mvnw deploy:deploy-file -DgroupId=org -DartifactId=petclinic -Dversion=${RELEASE_VERSION} -Dpackaging=jar -Dfile=petclinic-${RELEASE_VERSION}.jar -DrepositoryId=maven-releases -Durl=${NEXUS_RELEASE_URL} --settings settings.xml"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue