Fix bug that was cleaning up the levels too early
This commit is contained in:
parent
9f140b0147
commit
6c91d2a0e4
|
@ -2,7 +2,7 @@ def projects2artifacts = [:]
|
||||||
def artifacts2projects = [:]
|
def artifacts2projects = [:]
|
||||||
def modules2deps = [:]
|
def modules2deps = [:]
|
||||||
def alreadyInTheTree = []
|
def alreadyInTheTree = []
|
||||||
def inputProject = params.jenkins_project
|
def inputProject = params.jenkins_project.trim()
|
||||||
def report = [:]
|
def report = [:]
|
||||||
report['project'] = inputProject
|
report['project'] = inputProject
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ pipeline {
|
||||||
def downstreamdeps = [:]
|
def downstreamdeps = [:]
|
||||||
report['downstream_modules'] = [:]
|
report['downstream_modules'] = [:]
|
||||||
report['downstream_projects'] = []
|
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 ->
|
projects2artifacts[inputProject].each { a ->
|
||||||
if (a.split(':').length > 1) { //skip the parent (only groupId)
|
if (a.split(':').length > 1) { //skip the parent (only groupId)
|
||||||
report = analyzeDependency(modules2deps, alreadyInTheTree, artifacts2projects, report, a, 1) }
|
report = analyzeDependency(modules2deps, alreadyInTheTree, artifacts2projects, report, a, 1) }
|
||||||
|
@ -76,7 +76,7 @@ def findDownstreamDependencies(modules2deps, artifact) {
|
||||||
def downdeps = []
|
def downdeps = []
|
||||||
//println "Looking for users of ${artifact}"
|
//println "Looking for users of ${artifact}"
|
||||||
modules2deps.each { k, v -> if (v.contains("${artifact}")) downdeps << k }
|
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
|
//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
|
// 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
|
def nextDepth = ++depth
|
||||||
report['downstream_modules']["L${nextDepth}"] = [:]
|
|
||||||
downdeps.each { d ->
|
downdeps.each { d ->
|
||||||
if (!skipTree) {
|
if (!skipTree) {
|
||||||
report['downstream_modules'][level][artifact]['projects'] << artifacts2projects[d]
|
report['downstream_modules'][level][artifact]['projects'] << artifacts2projects[d]
|
||||||
report['downstream_projects'] << artifacts2projects[d]
|
report['downstream_projects'] << artifacts2projects[d]
|
||||||
}
|
}
|
||||||
// go recursive
|
// go recursive
|
||||||
analyzeDependency(modules2deps, alreadyInTheTree, artifacts2projects, report, d, nextDepth)
|
report = analyzeDependency(modules2deps, alreadyInTheTree, artifacts2projects, report, d, nextDepth)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
report
|
report
|
||||||
|
|
Loading…
Reference in New Issue