mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-05-28 14:19:38 +00:00
jenmkinsfile
This commit is contained in:
parent
cd4976f64e
commit
d3143ba0ce
1 changed files with 53 additions and 68 deletions
121
Jenkinsfile
vendored
121
Jenkinsfile
vendored
|
@ -1,73 +1,58 @@
|
|||
pipeline {
|
||||
agent any
|
||||
tools {
|
||||
maven 'maven-3'
|
||||
}
|
||||
environment {
|
||||
JFROG_CLI_BUILD_NAME = "spring-petclinic"
|
||||
JFROG_CLI_BUILD_NUMBER = "${BUILD_ID}"
|
||||
ARTIFACTORY_URL = "https://trialt0zppb.jfrog.io/"
|
||||
JF = "${WORKSPACE}/jf"
|
||||
}
|
||||
stages {
|
||||
stage('Download JFrog CLI') {
|
||||
steps {
|
||||
sh '''
|
||||
curl -fL https://releases.jfrog.io/artifactory/jfrog-cli/v2-jf/2.74.1/jfrog-cli-linux-arm64/jf -o "$JF"
|
||||
chmod +x "$JF"
|
||||
'''
|
||||
}
|
||||
agent any
|
||||
tools {
|
||||
maven 'maven-3'
|
||||
}
|
||||
stage('Configure JFrog CLI') {
|
||||
steps {
|
||||
withCredentials([usernamePassword(credentialsId: 'jfrog-saas', usernameVariable: 'ARTIFACTORY_USER', passwordVariable: 'ARTIFACTORY_PASSWORD')]) {
|
||||
sh '''
|
||||
"$JF" c add petclinic \
|
||||
--url="${ARTIFACTORY_URL}" \
|
||||
--user="$ARTIFACTORY_USER" \
|
||||
--password="$ARTIFACTORY_PASSWORD" \
|
||||
--interactive=false \
|
||||
--enc-password=false
|
||||
'''
|
||||
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}"
|
||||
}
|
||||
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}
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Validate Connection') {
|
||||
steps {
|
||||
sh '"$JF" c use petclinic'
|
||||
sh '"$JF" rt ping'
|
||||
sh '"$JF" c show petclinic'
|
||||
}
|
||||
post {
|
||||
always {
|
||||
echo "Build complete: ${env.JFROG_CLI_BUILD_NAME} #${env.BUILD_NUMBER}"
|
||||
}
|
||||
}
|
||||
stage('Build Maven') {
|
||||
steps {
|
||||
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 \
|
||||
--build-name="$JFROG_CLI_BUILD_NAME" \
|
||||
--build-number="$JFROG_CLI_BUILD_NUMBER"
|
||||
'''
|
||||
}
|
||||
}
|
||||
stage('Publish Build Info') {
|
||||
steps {
|
||||
sh '"$JF" rt build-collect-env'
|
||||
sh '"$JF" rt build-add-git'
|
||||
sh '"$JF" rt build-publish'
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
echo "Build complete: ${env.JFROG_CLI_BUILD_NAME} #${env.BUILD_NUMBER}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue