spring-petclinic/Jenkinsfile

77 lines
1.9 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 {
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-26 16:43:38 +00:00
ARTIFACTORY_URL = "http://artifactory.artifactory.svc.cluster.local:8081"
2025-03-26 16:35:03 +00:00
JF = "${WORKSPACE}/jf"
2025-03-25 19:11:30 +00:00
}
2025-03-25 23:55:05 +00:00
stages {
2025-03-26 00:05:02 +00:00
2025-03-25 23:59:54 +00:00
stage('Download JFrog CLI') {
steps {
sh '''
2025-03-26 16:40:51 +00:00
curl -fL https://releases.jfrog.io/artifactory/jfrog-cli/v2-jf/2.74.1/jfrog-cli-linux-arm64/jf -o "$JF"
2025-03-26 16:35:03 +00:00
chmod +x "$JF"
2025-03-25 23:59:54 +00:00
'''
}
}
2025-03-25 23:55:05 +00:00
stage('Configure JFrog CLI') {
steps {
withCredentials([usernamePassword(credentialsId: 'jfrog-platform-creds', usernameVariable: 'ARTIFACTORY_USER', passwordVariable: 'ARTIFACTORY_PASSWORD')]) {
sh '''
2025-03-26 16:35:03 +00:00
"$JF" c add petclinic \
--url="${ARTIFACTORY_URL}" \
--user="$ARTIFACTORY_USER" \
--password="$ARTIFACTORY_PASSWORD" \
2025-03-26 16:45:21 +00:00
--interactive=false \
2025-03-26 16:43:38 +00:00
--enc-password=false
2025-03-25 23:55:05 +00:00
'''
}
}
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-26 16:35:03 +00:00
sh '"$JF" c use petclinic'
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 '''
2025-03-26 16:35:03 +00:00
"$JF" mvnc --global \
2025-03-25 23:48:12 +00:00
--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
'''
2025-03-26 16:35:03 +00:00
sh '"$JF" mvn clean deploy -DskipTests -Dcheckstyle.skip=true'
2025-03-25 19:11:30 +00:00
}
}
stage('Publish Build Info') {
steps {
2025-03-26 16:35:03 +00:00
sh '"$JF" rt build-collect-env'
sh '"$JF" rt build-add-git'
sh '"$JF" rt build-publish'
2025-03-25 19:11:30 +00:00
}
}
}
2025-03-25 23:48:12 +00:00
post {
always {
2025-03-25 23:51:18 +00:00
echo "Build complete: ${env.JFROG_CLI_BUILD_NAME} #${env.BUILD_NUMBER}"
2025-03-25 23:48:12 +00:00
}
}
2025-03-25 19:11:30 +00:00
}