Generate and print the dependency report.

master
Manuele Simi 4 years ago
parent c36f5e3713
commit 307510c896

67
Jenkinsfile vendored

@ -4,6 +4,8 @@ def projects2artifacts = [:]
def artifacts2projects = [:]
def modules2deps = [:]
def inputProject = 'storagehub-client-library'
def report = [:]
report['project'] = inputProject
pipeline {
agent {
@ -39,20 +41,30 @@ pipeline {
stage('find downstream projects') {
steps {
script {
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 = [:]
projects2artifacts[inputProject].each { a ->
downstreamdeps[a] = []
downstreamdeps[a].addAll(findDownstreamDependencies(modules2deps, a))
println "${a} is used by ${downstreamdeps[a]}"
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 ->
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]}" }
}
}
// then we look for the projects that build the downstream dependencies
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…
Cancel
Save