-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
61 lines (54 loc) · 2.4 KB
/
Jenkinsfile
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// pipeline {
// agent any
// stages {
// stage('Checkout') {
// steps {
// // Checkout the repository
// git branch: 'master', url: 'https://github.com/nitishdsharma/repo1'
// }
// }
// stage('Determine Changed Subdirectories') {
// steps {
// script {
// // Fetch latest changes
// sh 'git fetch --all'
// // Get the list of subdirectories under src that have recent changes
// def changedDirs = sh(
// script: '''
// git diff --name-only HEAD~1 -- src/ |
// grep '^src/[^/]*' |
// cut -d '/' -f 2 |
// sort -u
// ''',
// returnStdout: true
// ).trim().split('\n')
// // Print the changed subdirectories for verification
// echo "Subdirectories with recent changes under src:"
// changedDirs.each {
// echo it
// }
// // Set environment variable to pass the list to subsequent stages
// env.CHANGED_SUBDIRS = changedDirs.join(',')
// }
// }
// }
// // Example stage to demonstrate using the CHANGED_SUBDIRS variable
// // stage('Build or Deploy Changed Subdirectories') {
// // when {
// // expression { env.CHANGED_SUBDIRS != '' }
// // }
// // steps {
// // script {
// // // Split the CHANGED_SUBDIRS variable back into a list
// // def changedSubdirs = env.CHANGED_SUBDIRS.split(',')
// // // Perform actions on each changed subdirectory
// // changedSubdirs.each { subdir ->
// // // Example: Build or deploy each changed subdirectory
// // echo "Building or deploying ${subdir}..."
// // // Add your build or deployment steps here
// // }
// // }
// // }
// // }
// }
// }