Fetch projects that build the downstream dependencies.

This commit is contained in:
Manuele Simi 2020-03-10 22:36:20 -04:00
parent 3b500f54a0
commit c36f5e3713
1 changed files with 10 additions and 7 deletions

17
Jenkinsfile vendored
View File

@ -1,6 +1,7 @@
def counts = 0 def counts = 0
def projects2artifacts = [:] def projects2artifacts = [:]
def artifacts2projects = [:]
def modules2deps = [:] def modules2deps = [:]
def inputProject = 'storagehub-client-library' def inputProject = 'storagehub-client-library'
@ -14,7 +15,7 @@ pipeline {
script { script {
Jenkins.getInstance().getAllItems(TopLevelItem.class).each { p -> Jenkins.getInstance().getAllItems(TopLevelItem.class).each { p ->
projects2artifacts[p.name] = [] projects2artifacts[p.name] = []
p.getAllJobs().each { j -> projects2artifacts[p.name] << j.name } p.getAllJobs().each { j -> projects2artifacts[p.name] << j.name; artifacts2projects[j.name] = p.name }
} }
println "FOUND ${projects2artifacts.size()} projects" println "FOUND ${projects2artifacts.size()} projects"
projects2artifacts.each { k,v -> println ("PROJECT ${k} BUILDS ${v}") } projects2artifacts.each { k,v -> println ("PROJECT ${k} BUILDS ${v}") }
@ -39,18 +40,18 @@ pipeline {
steps { steps {
script { script {
println "PROJECT ${inputProject} BUILDS ${projects2artifacts[inputProject]} artifacts" println "PROJECT ${inputProject} BUILDS ${projects2artifacts[inputProject]} artifacts"
// first, let's find out what components depends on the project's artifacts // first, let's find out what components depends on the project's artifacts (i.e. downstream dependencies)
def downstreamdeps = [:] def downstreamdeps = [:]
projects2artifacts[inputProject].each { a -> projects2artifacts[inputProject].each { a ->
downstreamdeps[a] = [] downstreamdeps[a] = []
downstreamdeps[a] << findDownstreamDependencies(modules2deps, a) downstreamdeps[a].addAll(findDownstreamDependencies(modules2deps, a))
println "${a} is used by ${downstreamdeps[a]}" println "${a} is used by ${downstreamdeps[a]}"
} }
// then we look for the projects that build the downstream dependencies // then we look for the projects that build the downstream dependencies
//downstreamdeps.each { k, v -> downstreamdeps.each { k, v ->
// println "${k} is build by ${findProject()}" for (d in v) { println "${d} is build by ${artifacts2projects[d]}" }
//} }
} }
} }
} }
@ -65,7 +66,9 @@ def findDownstreamDependencies(modules2deps, artifact) {
def findProject(projects2artifacts, artifact) { def findProject(projects2artifacts, artifact) {
println "Looking for project that builds ${artifact}" println "Looking for project that builds ${artifact}"
projects2artifacts.find { k,v -> v.contains("${artifact}")}.first.key def name = ""
projects2artifacts.each { k,v -> if (v.contains("${artifact}")) name = k }
name
} }