feature/21176 #1
|
@ -1,15 +1,25 @@
|
||||||
|
def agent_root_folder = '/var/lib/jenkins/.m2'
|
||||||
def projects2artifacts = [:]
|
def projects2artifacts = [:]
|
||||||
def artifacts2projects = [:]
|
def artifacts2projects = [:]
|
||||||
def modules2deps = [:]
|
def modules2deps = [:]
|
||||||
def alreadyInTheTree = []
|
def alreadyInTheTree = []
|
||||||
def inputProject = params.jenkins_project.trim()
|
def inputProject = params.jenkins_project.trim()
|
||||||
def report = [:]
|
def report = [:]
|
||||||
|
|
||||||
report['project'] = inputProject
|
report['project'] = inputProject
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent {
|
agent {
|
||||||
label 'CD'
|
label 'CD'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
environment {
|
||||||
|
AGENT_ROOT_FOLDER = "${agent_root_folder}"
|
||||||
|
PIPELINE_BUILD_NUMBER = "${env.BUILD_NUMBER}"
|
||||||
|
WALKER_NOTES = "${agent_root_folder}/walker_notes.${PIPELINE_BUILD_NUMBER}.txt"
|
||||||
manuele.simi marked this conversation as resolved
Outdated
|
|||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
parameters {
|
parameters {
|
||||||
string(name: 'jenkins_project',
|
string(name: 'jenkins_project',
|
||||||
defaultValue: '',
|
defaultValue: '',
|
||||||
|
@ -69,6 +79,33 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// post-build actions
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
script {
|
||||||
|
sh '''
|
||||||
|
cp $WALKER_NOTES ./walker_notes.${PIPELINE_BUILD_NUMBER}.md
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
success {
|
||||||
|
echo 'The dependencies walker pipeline worked!'
|
||||||
|
emailext to: 'jenkinsbuilds@d4science.org',
|
||||||
|
subject: "[Jenkins WalkerPipeline D4S] build ${currentBuild.fullDisplayName} worked",
|
||||||
|
body: "Build time: ${currentBuild.durationString}. See ${env.BUILD_URL}"
|
||||||
|
emailext attachmentsPattern: "**/walker_notes.${PIPELINE_BUILD_NUMBER}.md",
|
||||||
|
to: 'jenkinsreleases@d4science.org',
|
||||||
|
subject: "Dependency Report for gCube component ${inputProject} (build #${PIPELINE_BUILD_NUMBER})",
|
||||||
|
body: "Downstream dependencies of ${inputProject}. See ${env.BUILD_URL}"
|
||||||
|
}
|
||||||
|
failure {
|
||||||
|
echo 'The dependencies walker pipeline has failed'
|
||||||
|
emailext attachLog: true,
|
||||||
|
to: 'jenkinsbuilds@d4science.org',
|
||||||
|
subject: "[JenkinsDependenciesWalker D4S] build ${currentBuild.fullDisplayName} failed for component ${inputProject}",
|
||||||
|
body: "Something is wrong with ${env.BUILD_URL}"
|
||||||
|
}
|
||||||
|
}
|
||||||
manuele.simi marked this conversation as resolved
manuele.simi
commented
Nice post block, it looks familiar... Nice post block, it looks familiar...
|
|||||||
|
|
||||||
}
|
}
|
||||||
// look for modules that use this artifact
|
// look for modules that use this artifact
|
||||||
|
@ -144,7 +181,16 @@ def printReport(report) {
|
||||||
text += "\n"
|
text += "\n"
|
||||||
}
|
}
|
||||||
println text
|
println text
|
||||||
|
appendNotes(text)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def appendNotes(report) {
|
||||||
|
sh("""#!/bin/bash
|
||||||
manuele.simi marked this conversation as resolved
manuele.simi
commented
You don't need the shebang here. You don't need the shebang here.
roberto.cirillo
commented
Are you referring to the bash shell? I've used the bash shell otherwise the 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?
manuele.simi
commented
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.
roberto.cirillo
commented
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.
|
|||||||
|
echo -e "${report}" > $WALKER_NOTES
|
||||||
|
""")
|
||||||
|
}
|
||||||
|
|
||||||
// debug job
|
// debug job
|
||||||
def printJob(job) {
|
def printJob(job) {
|
||||||
println("fullname ${job.fullName}")
|
println("fullname ${job.fullName}")
|
||||||
|
|
Loading…
Reference in New Issue
PIPELINE_BUILD_NUMBER
instead ofinputProject
to make the notes' filename unique..txt
.Thanks Manuele for your feedback!
In order to preserve an unique filename as you suggest, I can add to the current filename, the
PIPELINE_BUILD_NUMBER
.WALKER_NOTES = "${agent_root_folder}/walker_notes.${inputProject}.${PIPELINE_BUILD_NUMBER}.md"
WALKER_NOTES = "${agent_root_folder}/walker_notes.${inputProject}.${PIPELINE_BUILD_NUMBER}.txt"
Well, it's a filename attached to an email with a subject related to the component. I mean, the filename should not really matter. And you could have issues with the component name in the filename.
Neverthlees, adding the pipeline number will make it unique.
OK I'm going to remove the component name from the filename