Pablo Solar VilariƱo
2020-06-16 b10099fdd337172e5d42b61a7394431d0356ae04
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
node {
    stage('Check changes') {
        checkout scm
    }
 
    // TODO: Jenkins can't execute pipelines for more than one project in the same run.
    // The CI task will fail if the change set includes changes across several projects
    // Ideas?
    // Changesets approach is not working as expected... TODO: Fix
    // runIfChanged('adopt-a-pup/web-app/')
    
    load "adopt-a-pup/web-app/Jenkinsfile"
}
 
 
@NonCPS
def runIfChanged(projectDir) {
    for (changeSet in currentBuild.changeSets) {
        for (changeItems in changeSet.getItems()) {
            for (file in changeItems.getAffectedFiles()) {
                if (file.getPath().startsWith(projectDir)) {
                    load "$projectDir/Jenkinsfile"
                }
            }
        }
    }
    return false
}