mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-15 20:35:49 +00:00
adding Jenkinsfile
This commit is contained in:
parent
381e7d1f14
commit
efba1926cc
1 changed files with 60 additions and 0 deletions
60
Jenkinsfile
vendored
Normal file
60
Jenkinsfile
vendored
Normal file
|
@ -0,0 +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}"
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Clone Repo') {
|
||||||
|
steps {
|
||||||
|
git branch: 'main', url: 'https://github.com/your-org/your-repo.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'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Docker Build and Push') {
|
||||||
|
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}")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue