jenmkinsfile

This commit is contained in:
Jesse Houldsworth 2025-03-27 11:36:36 -07:00
parent 8d83725287
commit cd4976f64e

77
Jenkinsfile vendored
View file

@ -4,45 +4,64 @@ pipeline {
maven 'maven-3'
}
environment {
JFROG_URL = "https://trialt0zppb.jfrog.io/artifactory"
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}"
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') {
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
'''
}
}
}
stage('Validate Connection') {
steps {
sh '"$JF" c use petclinic'
sh '"$JF" rt ping'
sh '"$JF" c show petclinic'
}
}
stage('Build Maven') {
steps {
script {
def server = Artifactory.server(env.JFROG_CREDENTIALS_ID)
// Run Maven Build
sh 'mvn clean install -DskipTests -Dcheckstyle.skip=true'
// Upload artifacts to Artifactory
server.upload spec: """{
"files": [
{
"pattern": "target/*.jar",
"target": "${JFROG_REPO_RELEASES}/"
}
]
}"""
}
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 {
script {
def server = Artifactory.server(env.JFROG_CREDENTIALS_ID)
def buildInfo = Artifactory.newBuildInfo()
buildInfo.name = env.JFROG_CLI_BUILD_NAME
buildInfo.number = env.JFROG_CLI_BUILD_NUMBER
server.publishBuildInfo(buildInfo)
}
sh '"$JF" rt build-collect-env'
sh '"$JF" rt build-add-git'
sh '"$JF" rt build-publish'
}
}
}