Fix bug that was cleaning up the levels too early

master
Manuele Simi 4 years ago
parent 9f140b0147
commit 6c91d2a0e4

11
Jenkinsfile vendored

@ -2,7 +2,7 @@ def projects2artifacts = [:]
def artifacts2projects = [:]
def modules2deps = [:]
def alreadyInTheTree = []
def inputProject = params.jenkins_project
def inputProject = params.jenkins_project.trim()
def report = [:]
report['project'] = inputProject
@ -52,7 +52,7 @@ pipeline {
def downstreamdeps = [:]
report['downstream_modules'] = [:]
report['downstream_projects'] = []
report['downstream_modules']['L1'] = [:]
for ( level in 1..50 ) report['downstream_modules']["L${level}"] = [:] // can't initialize with withDefault closure in jenkins
projects2artifacts[inputProject].each { a ->
if (a.split(':').length > 1) { //skip the parent (only groupId)
report = analyzeDependency(modules2deps, alreadyInTheTree, artifacts2projects, report, a, 1) }
@ -76,7 +76,7 @@ def findDownstreamDependencies(modules2deps, artifact) {
def downdeps = []
//println "Looking for users of ${artifact}"
modules2deps.each { k, v -> if (v.contains("${artifact}")) downdeps << k }
downdeps
return downdeps
}
//build the report of the given dependency, go recursive on its dependencies
@ -98,16 +98,15 @@ def analyzeDependency(modules2deps, alreadyInTheTree, artifacts2projects, report
}
// then we look for the projects that build the downstream dependencies and finally we go recursive
if (downdeps) {
if (downdeps.size() > 0) {
def nextDepth = ++depth
report['downstream_modules']["L${nextDepth}"] = [:]
downdeps.each { d ->
if (!skipTree) {
report['downstream_modules'][level][artifact]['projects'] << artifacts2projects[d]
report['downstream_projects'] << artifacts2projects[d]
}
// go recursive
analyzeDependency(modules2deps, alreadyInTheTree, artifacts2projects, report, d, nextDepth)
report = analyzeDependency(modules2deps, alreadyInTheTree, artifacts2projects, report, d, nextDepth)
}
}
report

Loading…
Cancel
Save