mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-15 12:25:50 +00:00
jenkinsfile
This commit is contained in:
parent
efba1926cc
commit
3f3d898dae
1 changed files with 35 additions and 34 deletions
69
Jenkinsfile
vendored
69
Jenkinsfile
vendored
|
@ -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
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue