Stages to navigate projects and maven modules.
This commit is contained in:
commit
dfedf4160d
|
@ -0,0 +1,46 @@
|
|||
|
||||
def counts = 0
|
||||
def projects2artifacts=[:]
|
||||
def modules2deps=[:]
|
||||
|
||||
pipeline {
|
||||
agent {
|
||||
label 'CD'
|
||||
}
|
||||
stages {
|
||||
stage('walking projects') {
|
||||
steps {
|
||||
script {
|
||||
Jenkins.getInstance().getAllItems(TopLevelItem.class).each { p ->
|
||||
projects2artifacts[p.name] = []
|
||||
p.getAllJobs().each { j -> projects2artifacts[p.name] << j.name }
|
||||
}
|
||||
println "FOUND ${projects2artifacts.size()} projects"
|
||||
projects2artifacts.each { k,v -> println ("PROJECT ${k} BUILDS ${v}") }
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('walking maven modules') {
|
||||
steps {
|
||||
script {
|
||||
// get all the maven modules and their dependencies
|
||||
Jenkins.getInstance().getAllItems(hudson.maven.MavenModule.class).each { m ->
|
||||
modules2deps[m.name] = []
|
||||
m.getDependencies().each { d -> modules2deps[m.name] << d.toString() }
|
||||
}
|
||||
println "FOUND ${modules2deps.size()} modules"
|
||||
modules2deps.each { k,v -> println ("MODULE ${k} DEPENDS on ${v}") }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
def printJob(job) {
|
||||
println("fullname ${job.fullName}")
|
||||
println("name ${job.name}")
|
||||
println("display name ${job.displayName}")
|
||||
job.getAllJobs().each {j -> println ("dep: ${j.name}")}
|
||||
}
|
||||
*/
|
|
@ -0,0 +1,16 @@
|
|||
#gCube Dependency Walker Pipeline
|
||||
Given a Jenkins project P:
|
||||
- navigate the maven modules built by P
|
||||
- return the list of projects that have modules depend on each maven module in P
|
||||
|
||||
Given a maven module's coordinates:
|
||||
- return the list of Jenkins projects that have modules depend on the input maven module
|
||||
|
||||
|
||||
## Requirements
|
||||
* [Jenkins](https://jenkins.io/) ver. 2.164.2 or newer
|
||||
* [Pipeline plugin](https://wiki.jenkins.io/display/JENKINS/Pipeline+Plugin)
|
||||
* [Pipeline: Maven](https://plugins.jenkins.io/pipeline-maven)
|
||||
* [Pipeline: Basic Steps](https://plugins.jenkins.io/workflow-basic-steps)
|
||||
* [Pipeline: Dependency Walker](https://plugins.jenkins.io/pipeline-dependency-walker/)
|
||||
* [NodeLabelParameter](https://plugins.jenkins.io/nodelabelparameter) (to allow to dynamically select the node on which a job should be executed)
|
Loading…
Reference in New Issue