feature/21176 #1

Merged
roberto.cirillo merged 10 commits from feature/21176 into master 2021-11-18 16:15:02 +01:00
1 changed files with 10 additions and 35 deletions
Showing only changes of commit bd23fde2d1 - Show all commits

45
Jenkinsfile vendored
View File

@ -1,9 +1,11 @@
def agent_root_folder = '/var/lib/jenkins/.m2'
def projects2artifacts = [:]
def artifacts2projects = [:]
def modules2deps = [:]
def alreadyInTheTree = []
def inputProject = params.jenkins_project.trim()
def report = [:]
report['project'] = inputProject
pipeline {
@ -14,7 +16,7 @@ pipeline {
environment {
AGENT_ROOT_FOLDER = "${agent_root_folder}"
PIPELINE_BUILD_NUMBER = "${env.BUILD_NUMBER}"
WALKER_NOTES = "${agent_root_folder}/walker_notes.${pipeline_build_number}.md"
WALKER_NOTES = "${agent_root_folder}/walker_notes.${inputProject}.md"
}
@ -83,7 +85,7 @@ pipeline {
script {
sh '''
cp $WALKER_NOTES ./walker_notes.${PIPELINE_BUILD_NUMBER}.md
cat ./$WALKER_NOTES
cat ./walker_notes.${PIPELINE_BUILD_NUMBER}.md
'''
}
}
@ -180,43 +182,16 @@ def printReport(report) {
text += "\n"
}
println text
appendNotes(text)
}
// print the final report
def saveReport(report) {
def text = ''
def indent = '\t'
text += "Dependency Report for ${report['project']}"
text += "\n\n"
text += "|--Project Maven Modules\n"
report['downstream_modules'].each { depth, artifacts ->
artifacts.each { name, data ->
text += "${indent}|--Module: ${name}\n"
text += "${indent * 2}|--Deepest Dependency Level: ${depth}\n"
text += "${indent * 2}|--Used by (Maven Modules)\n"
data['dependencies'].each { d ->
text += "${indent * 3}|--${d}"
text += "\n"
}
text += "${indent * 2}|--Referred by (Jenkins Projects)\n"
data['projects'].each { p ->
text += "${indent * 3}|--${p}"
text += "\n"
}
}
}
text += "\n\n"
text += "|--All Downstream Projects\n"
report['downstream_projects'].unique().sort()
report['downstream_projects'].each { p ->
text += "${indent}|--${p}"
text += "\n"
}
text > WALKER_NOTES
def appendNotes(report) {
manuele.simi marked this conversation as resolved
Review

You don't need the shebang here.

You don't need the shebang here.
Review

Are you referring to the bash shell?

I've used the bash shell otherwise the echo -e option doesn't work.

Is there an easier way to do that?

Are you referring to the bash shell? I've used the bash shell otherwise the `echo -e` option doesn't work. Is there an easier way to do that?
Review

echo (without -e) works for sure without the shebang.

But if it does work for you, leave like that. It's a detail.

`echo` (without -e) works for sure without the shebang. But if it does work for you, leave like that. It's a detail.
Review

echo (without -e) works for sure without the shebang.

But if it does work for you, leave like that. It's a detail.

Yes it works but without the "-e" option the backslashes are not escapes. The result is an unreadable file.

> `echo` (without -e) works for sure without the shebang. > > But if it does work for you, leave like that. It's a detail. > Yes it works but without the "-e" option the backslashes are not escapes. The result is an unreadable file.
sh("""
echo "${report}" >> $WALKER_NOTES
""")
}
// debug job
def printJob(job) {
println("fullname ${job.fullName}")