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 46 additions and 0 deletions

46
Jenkinsfile vendored
View File

@ -1,15 +1,25 @@
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 {
agent {
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"
}
parameters {
string(name: 'jenkins_project',
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
Review

Nice post block, it looks familiar...

Nice post block, it looks familiar...
}
// look for modules that use this artifact
@ -144,7 +181,16 @@ def printReport(report) {
text += "\n"
}
println text
appendNotes(text)
}
def appendNotes(report) {
sh("""#!/bin/bash
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.
echo -e "${report}" > $WALKER_NOTES
""")
}
// debug job
def printJob(job) {
println("fullname ${job.fullName}")