File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ pipeline {
2+ agent any
3+ tools {
4+ // Specify the Gradle version configured in Jenkins
5+ gradle ' Gradle'
6+ // Specify the JDK version configured in Jenkins
7+ jdk ' Java 21'
8+ }
9+ stages {
10+ stage(' Checkout' ) {
11+ steps {
12+ // Checkout code from SCM (e.g., Git)
13+ checkout scm
14+ }
15+ }
16+ stage(' Build' ) {
17+ steps {
18+ // Run Gradle build
19+ sh ' ./gradlew clean build'
20+ }
21+ }
22+ stage(' Publish Artifacts' ) {
23+ when {
24+ // Only publish for main branch
25+ branch ' main'
26+ }
27+ steps {
28+ // Archive build artifacts
29+ archiveArtifacts artifacts : ' build/libs/*.jar' , allowEmptyArchive : true
30+ }
31+ }
32+ }
33+ post {
34+ always {
35+ // Clean workspace after build
36+ cleanWs()
37+ }
38+ success {
39+ // Notify on success
40+ echo ' Build and tests completed successfully!'
41+ }
42+ failure {
43+ // Notify on failure
44+ echo ' Build or tests failed!'
45+ }
46+ }
47+ }
You can’t perform that action at this time.
0 commit comments