From 3f3d898daed403aa729cabe07bdd6b76a5ad2a2a Mon Sep 17 00:00:00 2001 From: Jesse Houldsworth Date: Tue, 25 Mar 2025 12:48:00 -0700 Subject: [PATCH] jenkinsfile --- Jenkinsfile | 69 +++++++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bbcae9e57..b3adfcd22 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,59 +1,60 @@ pipeline { agent any - tools { - maven 'maven-3' // your Maven tool label - } - environment { - ARTIFACTORY_URL = 'http://localhost:8081/artifactory' - BUILD_NAME = "spring-petclinic" - BUILD_NUMBER = "${BUILD_ID}" - DOCKER_IMAGE = "localhost:8081/petclinic-docker-dev-local/spring-petclinic:${BUILD_ID}" + JFROG_CLI_BUILD_NAME = "spring-petclinic" + JFROG_CLI_BUILD_NUMBER = "${BUILD_ID}" } stages { - stage('Clone Repo') { + stage('Setup JFrog CLI') { steps { - git branch: 'main', url: 'https://github.com/your-org/your-repo.git' + jfrog rt config --server-id-resolve jfrog-local --server-id-deploy jfrog-local + } + } + + stage('Checkout') { + steps { + git branch: 'main', url: 'https://github.com/JesseHouldsworth/spring-petclinic.git' } } stage('Build with Maven') { steps { - rtMavenRun ( - tool: 'maven-3', - pom: 'pom.xml', - goals: 'clean install -DskipTests=true -Denforcer.skip=true', - resolverId: 'maven-resolver', - deployerId: 'maven-deployer' - ) + sh ''' + jf mvnc --global \ + --repo-resolve-releases=libs-release-local \ + --repo-resolve-snapshots=libs-snapshot-local + jf mvn clean install -DskipTests=true -Denforcer.skip=true + ''' } } - stage('Docker Build and Push') { + stage('Build Docker Image') { steps { - script { - docker.build("${DOCKER_IMAGE}") - def server = Artifactory.server('artifactory-creds') - server.dockerPush( - image: "${DOCKER_IMAGE}", - targetRepo: 'petclinic-docker-dev-local', - buildInfo: Artifactory.newBuildInfo().name("${BUILD_NAME}").number("${BUILD_NUMBER}") - ) - } + sh """ + docker build -t localhost:8081/petclinic-docker-dev-local/spring-petclinic:${BUILD_ID} . + """ + } + } + + stage('Push Docker Image') { + steps { + sh """ + jf docker-push \ + localhost:8081/petclinic-docker-dev-local/spring-petclinic:${BUILD_ID} \ + petclinic-docker-dev-local + """ } } stage('Publish Build Info') { steps { - script { - def server = Artifactory.server('artifactory-creds') - def buildInfo = Artifactory.newBuildInfo() - buildInfo.name = "${BUILD_NAME}" - buildInfo.number = "${BUILD_NUMBER}" - server.publishBuildInfo(buildInfo) - } + sh ''' + jf rt build-collect-env + jf rt build-add-git + jf rt build-publish + ''' } } }