Generate and print the dependency report.
This commit is contained in:
parent
c36f5e3713
commit
307510c896
|
@ -4,6 +4,8 @@ def projects2artifacts = [:]
|
|||
def artifacts2projects = [:]
|
||||
def modules2deps = [:]
|
||||
def inputProject = 'storagehub-client-library'
|
||||
def report = [:]
|
||||
report['project'] = inputProject
|
||||
|
||||
pipeline {
|
||||
agent {
|
||||
|
@ -42,18 +44,28 @@ pipeline {
|
|||
println "PROJECT ${inputProject} BUILDS ${projects2artifacts[inputProject]} artifacts"
|
||||
// first, let's find out what components depends on the project's artifacts (i.e. downstream dependencies)
|
||||
def downstreamdeps = [:]
|
||||
report['downstream_modules'] = [:]
|
||||
report['downstream_projects'] = []
|
||||
projects2artifacts[inputProject].each { a ->
|
||||
downstreamdeps[a] = []
|
||||
downstreamdeps[a].addAll(findDownstreamDependencies(modules2deps, a))
|
||||
println "${a} is used by ${downstreamdeps[a]}"
|
||||
report['downstream_modules'][a] = [:]
|
||||
report['downstream_modules'][a]['dependencies'] = []
|
||||
report['downstream_modules'][a]['projects'] = []
|
||||
}
|
||||
projects2artifacts[inputProject].each { a ->
|
||||
report['downstream_modules'][a]['dependencies'].addAll(findDownstreamDependencies(modules2deps, a))
|
||||
println "${a} is used by ${report['downstream_modules'][a]['dependencies']}"
|
||||
}
|
||||
|
||||
}
|
||||
// then we look for the projects that build the downstream dependencies
|
||||
downstreamdeps.each { k, v ->
|
||||
for (d in v) { println "${d} is build by ${artifacts2projects[d]}" }
|
||||
report['downstream_modules'].each { module, deps ->
|
||||
deps['dependencies'].each { d ->
|
||||
report['downstream_modules'][module]['projects'] << artifacts2projects[d]
|
||||
report['downstream_projects'] << artifacts2projects[d]
|
||||
}
|
||||
}
|
||||
}
|
||||
printReport(report)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +83,34 @@ def findProject(projects2artifacts, artifact) {
|
|||
name
|
||||
}
|
||||
|
||||
|
||||
def printReport(report) {
|
||||
def text = ''
|
||||
def indent = ''
|
||||
text += "Dependency Report for ${report['project']} (jenkins project)"
|
||||
text += "\n\n"
|
||||
text += "Project Modules\n"
|
||||
indent += '\t'
|
||||
report['downstream_modules'].each { module, deps ->
|
||||
text += "${indent}Module Name: ${module}\n"
|
||||
text += "${indent}\tDownstream Modules for ${module}\n"
|
||||
deps['dependencies'].each { d ->
|
||||
text += "${indent}\t\t${d}"
|
||||
text += "\n"
|
||||
}
|
||||
text += "${indent}\tDownstream Projects for ${module}\n"
|
||||
deps['projects'].each { p ->
|
||||
text += "${indent}\t\t${p}"
|
||||
text += "\n"
|
||||
}
|
||||
}
|
||||
text += "\n\n"
|
||||
text += "All Downstream Projects\n"
|
||||
report['downstream_projects'].each { p ->
|
||||
text += "${indent}${p}"
|
||||
text += "\n"
|
||||
}
|
||||
println text
|
||||
}
|
||||
/*
|
||||
def printJob(job) {
|
||||
println("fullname ${job.fullName}")
|
||||
|
|
Loading…
Reference in New Issue