spring-petclinic/Jenkinsfile

59 lines
1.8 KiB
Text
Raw Normal View History

2025-03-25 19:11:30 +00:00
pipeline {
2025-03-27 19:04:44 +00:00
agent any
tools {
maven 'maven-3'
2025-03-25 23:59:54 +00:00
}
2025-03-27 19:04:44 +00:00
environment {
JFROG_URL = "https://trialt0zppb.jfrog.io"
JFROG_REPO_RELEASES = "petclinic-maven-dev-local"
JFROG_REPO_SNAPSHOTS = "petclinic-maven-dev-virtual"
JFROG_CREDENTIALS_ID = 'jfrog-saas' // Jenkins credential ID (username + API key or password)
JFROG_CLI_BUILD_NAME = "spring-petclinic"
JFROG_CLI_BUILD_NUMBER = "${BUILD_ID}"
2025-03-27 18:36:36 +00:00
}
2025-03-27 19:04:44 +00:00
stages {
stage('Configure JFrog CLI') {
steps {
withCredentials([usernamePassword(credentialsId: "${env.JFROG_CREDENTIALS_ID}", usernameVariable: 'JFROG_USER', passwordVariable: 'JFROG_API_KEY')]) {
sh """
jfrog config add jenkins-config \\
--url=${JFROG_URL} \\
--user=$JFROG_USER \\
--apikey=$JFROG_API_KEY \\
--interactive=false
"""
}
}
}
stage('Build Maven') {
steps {
sh 'mvn clean install -DskipTests -Dcheckstyle.skip=true'
}
}
stage('Upload to Artifactory') {
steps {
sh """
jfrog rt u "target/*.jar" ${JFROG_REPO_RELEASES}/ \\
--build-name=${JFROG_CLI_BUILD_NAME} \\
--build-number=${JFROG_CLI_BUILD_NUMBER}
"""
}
}
stage('Publish Build Info') {
steps {
sh """
jfrog rt bp ${JFROG_CLI_BUILD_NAME} ${JFROG_CLI_BUILD_NUMBER}
"""
}
}
2025-03-27 18:36:36 +00:00
}
2025-03-27 19:04:44 +00:00
post {
always {
echo "Build complete: ${env.JFROG_CLI_BUILD_NAME} #${env.BUILD_NUMBER}"
}
2025-03-25 23:48:12 +00:00
}
2025-03-27 19:04:44 +00:00
}