groovy checkpoint

This commit is contained in:
moleksiienko 2025-01-13 00:32:09 +02:00
parent 6148ddd967
commit 1e1a85bb19
2 changed files with 61 additions and 0 deletions

View 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}"
}
}
}
}
}

View 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
}
}
}
}