mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-18 05:25:50 +00:00
Trigger Jenkins pipeline
This commit is contained in:
parent
5dc9cd7335
commit
dee648d982
1 changed files with 57 additions and 0 deletions
57
Jenkinsfile
vendored
Normal file
57
Jenkinsfile
vendored
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
pipeline {
|
||||||
|
agent any // This runs the pipeline on any available agent
|
||||||
|
|
||||||
|
environment {
|
||||||
|
// Set environment variables if needed
|
||||||
|
APP_DIR = "/home/vagrant/petclinic"
|
||||||
|
REPO_URL = "https://github.com/yiting68/spring-petclinic.git"
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Checkout') {
|
||||||
|
steps {
|
||||||
|
// Checkout the latest code from the Git repository
|
||||||
|
git branch: 'main', url: 'https://github.com/yiting68/spring-petclinic.git'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Build') {
|
||||||
|
steps {
|
||||||
|
// Install dependencies and build the project
|
||||||
|
sh './gradlew clean build' // assuming you are using Gradle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Test') {
|
||||||
|
steps {
|
||||||
|
// Run tests (JUnit tests in this case)
|
||||||
|
sh './gradlew test'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Deploy') {
|
||||||
|
steps {
|
||||||
|
// Deploy the app, e.g., run the JAR file or deploy to your server
|
||||||
|
sh 'vagrant up --provision'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
// Actions to perform after the pipeline finishes
|
||||||
|
echo 'Cleaning up'
|
||||||
|
deleteDir() // Clean up the workspace after the build
|
||||||
|
}
|
||||||
|
|
||||||
|
success {
|
||||||
|
// Actions if the pipeline is successful
|
||||||
|
echo 'Build and deploy succeeded!'
|
||||||
|
}
|
||||||
|
|
||||||
|
failure {
|
||||||
|
// Actions if the pipeline fails
|
||||||
|
echo 'Build failed!'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue