diff --git a/Jenkinsfile b/Jenkinsfile index f7605c8..8164eba 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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) { + sh(""" + echo "${report}" >> $WALKER_NOTES + """) } - // debug job def printJob(job) { println("fullname ${job.fullName}")