mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-04-24 19:32:49 +00:00
80 lines
2.7 KiB
Groovy
80 lines
2.7 KiB
Groovy
pipeline {
|
|
agent any
|
|
tools {
|
|
maven 'maven-3'
|
|
}
|
|
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'
|
|
JFROG_CLI_BUILD_NAME = "spring-petclinic"
|
|
JFROG_CLI_BUILD_NUMBER = "${BUILD_ID}"
|
|
JF = "${WORKSPACE}/jfrog"
|
|
}
|
|
stages {
|
|
stage('Download JFrog CLI') {
|
|
steps {
|
|
sh """
|
|
curl -fL https://releases.jfrog.io/artifactory/jfrog-cli/v2-jf/2.74.1/jfrog-cli-linux-amd64/jf -o "${JF}"
|
|
chmod +x "${JF}"
|
|
"""
|
|
}
|
|
}
|
|
|
|
stage('Configure JFrog CLI') {
|
|
steps {
|
|
withCredentials([usernamePassword(credentialsId: "${JFROG_CREDENTIALS_ID}", usernameVariable: 'JFROG_USER', passwordVariable: 'JFROG_API_KEY')]) {
|
|
sh """
|
|
${JF} config add jenkins-config \
|
|
--url=${JFROG_URL} \
|
|
--user=${JFROG_USER} \
|
|
--password=${JFROG_API_KEY} \
|
|
--interactive=false \
|
|
--overwrite=true
|
|
"""
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Build with Maven') {
|
|
steps {
|
|
sh """
|
|
${JF} mvnc --global \\
|
|
--repo-resolve-releases=${JFROG_REPO_SNAPSHOTS} \\
|
|
--repo-resolve-snapshots=${JFROG_REPO_SNAPSHOTS} \\
|
|
--repo-deploy-releases=${JFROG_REPO_RELEASES} \\
|
|
--repo-deploy-snapshots=${JFROG_REPO_RELEASES}
|
|
"""
|
|
sh """
|
|
${JF} mvn clean deploy -DskipTests -Dcheckstyle.skip=true \\
|
|
--build-name=${JFROG_CLI_BUILD_NAME} \\
|
|
--build-number=${JFROG_CLI_BUILD_NUMBER}
|
|
"""
|
|
}
|
|
}
|
|
|
|
stage('Publish Build Info') {
|
|
steps {
|
|
sh """
|
|
${JF} rt build-collect-env
|
|
${JF} rt build-add-git
|
|
${JF} rt build-publish
|
|
"""
|
|
}
|
|
}
|
|
|
|
stage('Xray Scan') {
|
|
steps {
|
|
// Use the new "jf build-scan" command
|
|
// "Fail Build" is decided by your Xray policy if severity >= High
|
|
sh "${JF} build-scan ${JFROG_CLI_BUILD_NAME} ${JFROG_CLI_BUILD_NUMBER} --fail=false"
|
|
}
|
|
}
|
|
}
|
|
post {
|
|
always {
|
|
echo "Build complete: ${env.JFROG_CLI_BUILD_NAME} #${env.BUILD_NUMBER}"
|
|
}
|
|
}
|
|
}
|