-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathjenkins-src-changes
More file actions
45 lines (41 loc) · 1.43 KB
/
jenkins-src-changes
File metadata and controls
45 lines (41 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
pipeline {
agent any
stages {
stage('Clone Repository') {
steps {
checkout([$class: 'GitSCM',
branches: [[name: '*/main']],
userRemoteConfigs: [[url: 'https://github.com/chinni4321/helloworld-project-1.git']]])
}
}
stage('Check changes in src') {
steps {
script {
def srcChanges = sh(
script: "git diff --quiet --exit-code HEAD~1..HEAD src",
returnStatus: true
)
if (srcChanges == 0) {
echo "No changes in the 'src' directory. Aborting the pipeline."
currentBuild.result = 'ABORTED'
error("Pipeline aborted due to no changes in 'src'")
} else {
echo "There are changes in the 'src' directory. Proceeding with the Maven build."
}
}
}
}
stage('Maven Build') {
when {
expression {
return currentBuild.resultIsBetterOrEqualTo('ABORTED')
}
}
steps {
// Add your Maven build steps here
sh 'mvn clean package'
}
}
// Add more stages as needed
}
}