mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-05-29 22:59: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 {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
tools {
|
tools {
|
||||||
maven 'maven-3'
|
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"
|
|
||||||
'''
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
stage('Configure JFrog CLI') {
|
environment {
|
||||||
steps {
|
JFROG_URL = "https://trialt0zppb.jfrog.io"
|
||||||
withCredentials([usernamePassword(credentialsId: 'jfrog-saas', usernameVariable: 'ARTIFACTORY_USER', passwordVariable: 'ARTIFACTORY_PASSWORD')]) {
|
JFROG_REPO_RELEASES = "petclinic-maven-dev-local"
|
||||||
sh '''
|
JFROG_REPO_SNAPSHOTS = "petclinic-maven-dev-virtual"
|
||||||
"$JF" c add petclinic \
|
JFROG_CREDENTIALS_ID = 'jfrog-saas' // Jenkins credential ID (username + API key or password)
|
||||||
--url="${ARTIFACTORY_URL}" \
|
JFROG_CLI_BUILD_NAME = "spring-petclinic"
|
||||||
--user="$ARTIFACTORY_USER" \
|
JFROG_CLI_BUILD_NUMBER = "${BUILD_ID}"
|
||||||
--password="$ARTIFACTORY_PASSWORD" \
|
}
|
||||||
--interactive=false \
|
stages {
|
||||||
--enc-password=false
|
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') {
|
post {
|
||||||
steps {
|
always {
|
||||||
sh '"$JF" c use petclinic'
|
echo "Build complete: ${env.JFROG_CLI_BUILD_NAME} #${env.BUILD_NUMBER}"
|
||||||
sh '"$JF" rt ping'
|
}
|
||||||
sh '"$JF" c show petclinic'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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