mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-19 14:25:50 +00:00
groovy checkpoint
This commit is contained in:
parent
6148ddd967
commit
1e1a85bb19
2 changed files with 61 additions and 0 deletions
43
cicd/jenkins-pipelines/build.groovy
Normal file
43
cicd/jenkins-pipelines/build.groovy
Normal file
|
@ -0,0 +1,43 @@
|
|||
pipeline {
|
||||
agent any
|
||||
triggers {
|
||||
pollSCM('H/5 * * * *') // Watches the `dev` branch
|
||||
}
|
||||
environment {
|
||||
DOCKERHUB_CREDENTIALS = credentials('nalexx6-dockerhub-pass')
|
||||
DOCKERHUB_USERNAME = "nalexxgd"
|
||||
NEXUS_URL = 'localhost:8081'
|
||||
}
|
||||
stages {
|
||||
stage('Checkout Code') {
|
||||
steps {
|
||||
git {
|
||||
url: 'git@github.com:Nalexx06/spring-petclinic.git'
|
||||
credentialsId: "nalexx06_github_ssh"
|
||||
branch: 'dev'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Build & Test') {
|
||||
steps {
|
||||
sh './mvnw clean verify'
|
||||
}
|
||||
}
|
||||
stage('Upload to Nexus') {
|
||||
steps {
|
||||
sh './mvnw deploy -DaltDeploymentRepository=snapshots::default::${NEXUS_URL}'
|
||||
}
|
||||
}
|
||||
stage('Build Docker Image') {
|
||||
steps {
|
||||
script {
|
||||
def version = sh(script: "mvn help:evaluate -Dexpression=project.version -q -DforceStdout", returnStdout: true).trim()
|
||||
sh "docker build -t petclinic:${version} ."
|
||||
sh "docker tag petclinic:${version} ${DOCKERHUB_USERNAME}/petclinic:${version}"
|
||||
sh "docker login -u ${DOCKERHUB_USERNAME} -p ${DOCKERHUB_CREDENTIALS}"
|
||||
sh "docker push ${DOCKERHUB_USERNAME}/petclinic:${version}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
18
cicd/jenkins-pipelines/precommit.groovy
Normal file
18
cicd/jenkins-pipelines/precommit.groovy
Normal file
|
@ -0,0 +1,18 @@
|
|||
pipeline {
|
||||
agent any
|
||||
triggers {
|
||||
pollSCM('H/5 * * * *') // Adjust polling interval as needed
|
||||
}
|
||||
stages {
|
||||
stage('Checkout Code') {
|
||||
steps {
|
||||
git url: 'https://github.com/spring-projects/spring-petclinic.git', branch: 'main'
|
||||
}
|
||||
}
|
||||
stage('Build & Test') {
|
||||
steps {
|
||||
sh './mvnw clean verify' // Uses Maven Wrapper to build and test
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue