jenkinsfile

This commit is contained in:
Jesse Houldsworth 2025-03-25 12:48:00 -07:00
parent efba1926cc
commit 3f3d898dae

67
Jenkinsfile vendored
View file

@ -1,59 +1,60 @@
pipeline { pipeline {
agent any agent any
tools {
maven 'maven-3' // your Maven tool label
}
environment { environment {
ARTIFACTORY_URL = 'http://localhost:8081/artifactory' JFROG_CLI_BUILD_NAME = "spring-petclinic"
BUILD_NAME = "spring-petclinic" JFROG_CLI_BUILD_NUMBER = "${BUILD_ID}"
BUILD_NUMBER = "${BUILD_ID}"
DOCKER_IMAGE = "localhost:8081/petclinic-docker-dev-local/spring-petclinic:${BUILD_ID}"
} }
stages { stages {
stage('Clone Repo') { stage('Setup JFrog CLI') {
steps { 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') { stage('Build with Maven') {
steps { steps {
rtMavenRun ( sh '''
tool: 'maven-3', jf mvnc --global \
pom: 'pom.xml', --repo-resolve-releases=libs-release-local \
goals: 'clean install -DskipTests=true -Denforcer.skip=true', --repo-resolve-snapshots=libs-snapshot-local
resolverId: 'maven-resolver', jf mvn clean install -DskipTests=true -Denforcer.skip=true
deployerId: 'maven-deployer' '''
)
} }
} }
stage('Docker Build and Push') { stage('Build Docker Image') {
steps { steps {
script { sh """
docker.build("${DOCKER_IMAGE}") docker build -t localhost:8081/petclinic-docker-dev-local/spring-petclinic:${BUILD_ID} .
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}")
)
} }
} }
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') { stage('Publish Build Info') {
steps { steps {
script { sh '''
def server = Artifactory.server('artifactory-creds') jf rt build-collect-env
def buildInfo = Artifactory.newBuildInfo() jf rt build-add-git
buildInfo.name = "${BUILD_NAME}" jf rt build-publish
buildInfo.number = "${BUILD_NUMBER}" '''
server.publishBuildInfo(buildInfo)
}
} }
} }
} }