jenmkinsfile

This commit is contained in:
Jesse Houldsworth 2025-03-27 12:17:07 -07:00
parent d3143ba0ce
commit b5e0c219cf

57
Jenkinsfile vendored
View file

@ -7,46 +7,59 @@ pipeline {
JFROG_URL = "https://trialt0zppb.jfrog.io" JFROG_URL = "https://trialt0zppb.jfrog.io"
JFROG_REPO_RELEASES = "petclinic-maven-dev-local" JFROG_REPO_RELEASES = "petclinic-maven-dev-local"
JFROG_REPO_SNAPSHOTS = "petclinic-maven-dev-virtual" JFROG_REPO_SNAPSHOTS = "petclinic-maven-dev-virtual"
JFROG_CREDENTIALS_ID = 'jfrog-saas' // Jenkins credential ID (username + API key or password) JFROG_CREDENTIALS_ID = 'jfrog-saas'
JFROG_CLI_BUILD_NAME = "spring-petclinic" JFROG_CLI_BUILD_NAME = "spring-petclinic"
JFROG_CLI_BUILD_NUMBER = "${BUILD_ID}" JFROG_CLI_BUILD_NUMBER = "${BUILD_ID}"
JF = "${WORKSPACE}/jfrog" // Local CLI path
} }
stages { 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') { stage('Configure JFrog CLI') {
steps { steps {
withCredentials([usernamePassword(credentialsId: "${env.JFROG_CREDENTIALS_ID}", usernameVariable: 'JFROG_USER', passwordVariable: 'JFROG_API_KEY')]) { withCredentials([usernamePassword(credentialsId: "${JFROG_CREDENTIALS_ID}", usernameVariable: 'JFROG_USER', passwordVariable: 'JFROG_API_KEY')]) {
sh """ sh '''
jfrog config add jenkins-config \\ "$JF" config add jenkins-config \
--url=${JFROG_URL} \\ --url="${JFROG_URL}" \
--user=$JFROG_USER \\ --user="$JFROG_USER" \
--apikey=$JFROG_API_KEY \\ --apikey="$JFROG_API_KEY" \
--interactive=false --interactive=false
""" '''
} }
} }
} }
stage('Build Maven') { stage('Build Maven') {
steps { steps {
sh 'mvn clean install -DskipTests -Dcheckstyle.skip=true' sh '''
} "$JF" mvnc --global \
} --repo-resolve-releases=${JFROG_REPO_SNAPSHOTS} \
--repo-resolve-snapshots=${JFROG_REPO_SNAPSHOTS} \
stage('Upload to Artifactory') { --repo-deploy-releases=${JFROG_REPO_RELEASES} \
steps { --repo-deploy-snapshots=${JFROG_REPO_RELEASES}
sh """ '''
jfrog rt u "target/*.jar" ${JFROG_REPO_RELEASES}/ \\ sh '''
--build-name=${JFROG_CLI_BUILD_NAME} \\ "$JF" mvn clean deploy -DskipTests -Dcheckstyle.skip=true \
--build-number=${JFROG_CLI_BUILD_NUMBER} --build-name="$JFROG_CLI_BUILD_NAME" \
""" --build-number="$JFROG_CLI_BUILD_NUMBER"
'''
} }
} }
stage('Publish Build Info') { stage('Publish Build Info') {
steps { steps {
sh """ sh '''
jfrog rt bp ${JFROG_CLI_BUILD_NAME} ${JFROG_CLI_BUILD_NUMBER} "$JF" rt build-collect-env
""" "$JF" rt build-add-git
"$JF" rt build-publish
'''
} }
} }
} }