spring-petclinic/Jenkinsfile

68 lines
1.6 KiB
Text
Raw Normal View History

2025-03-25 19:11:30 +00:00
pipeline {
agent any
2025-03-25 20:13:24 +00:00
tools {
jfrog 'jfrog-cli'
2025-03-25 20:19:41 +00:00
maven 'maven-3'
2025-03-25 20:13:24 +00:00
}
2025-03-25 19:11:30 +00:00
environment {
2025-03-25 19:48:00 +00:00
JFROG_CLI_BUILD_NAME = "spring-petclinic"
JFROG_CLI_BUILD_NUMBER = "${BUILD_ID}"
2025-03-25 23:48:12 +00:00
ARTIFACTORY_URL = "http://artifactory.artifactory.svc.cluster.local:8081/artifactory"
2025-03-25 19:11:30 +00:00
}
stages {
2025-03-25 23:48:12 +00:00
stage('Configure JFrog CLI') {
2025-03-25 19:11:30 +00:00
steps {
2025-03-25 23:48:12 +00:00
withCredentials([usernamePassword(credentialsId: 'artifactory-creds', usernameVariable: 'ARTIFACTORY_USER', passwordVariable: 'ARTIFACTORY_PASSWORD')]) {
sh '''
jf c show petclinic || jf c add petclinic \
--url=${ARTIFACTORY_URL} \
--user=${ARTIFACTORY_USER} \
--password=${ARTIFACTORY_PASSWORD} \
--interactive=false
jf use petclinic
'''
}
2025-03-25 19:11:30 +00:00
}
}
2025-03-25 23:48:12 +00:00
stage('Validate Connection') {
2025-03-25 19:11:30 +00:00
steps {
2025-03-25 23:48:12 +00:00
sh 'jf rt ping'
2025-03-25 19:11:30 +00:00
}
}
2025-03-25 23:48:12 +00:00
stage('Build Maven') {
2025-03-25 19:11:30 +00:00
steps {
2025-03-25 23:48:12 +00:00
sh 'chmod +x mvnw'
sh '''
jf mvnc --global \
--repo-resolve-releases=petclinic-maven-dev-virtual \
--repo-resolve-snapshots=petclinic-maven-dev-virtual \
--repo-deploy-releases=petclinic-maven-dev-local \
--repo-deploy-snapshots=petclinic-maven-dev-local
'''
sh 'jf mvn clean deploy -DskipTests -Dcheckstyle.skip=true'
2025-03-25 19:11:30 +00:00
}
}
stage('Publish Build Info') {
steps {
2025-03-25 23:48:12 +00:00
sh '''
jf rt build-collect-env
jf rt build-add-git
jf rt build-publish
'''
2025-03-25 19:11:30 +00:00
}
}
}
2025-03-25 23:48:12 +00:00
post {
always {
echo "Build complete: $JFROG_CLI_BUILD_NAME #$JFROG_CLI_BUILD_NUMBER"
}
}
2025-03-25 19:11:30 +00:00
}