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"
manuele.simi marked this conversation as resolved Outdated
  1. I'd use PIPELINE_BUILD_NUMBER instead of inputProject to make the notes' filename unique.
  2. I don't see any markdown formatting in the report, I'd change the extension to .txt.
1. I'd use `PIPELINE_BUILD_NUMBER` instead of `inputProject` to make the notes' filename unique. 2. I don't see any markdown formatting in the report, I'd change the extension to `.txt`.

Thanks Manuele for your feedback!

  1. I think it's more useful to have the component name specified in the filename rather than the build number: in this way is more easily to identify the component to which it refers.
    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"

  1. you're absolutely right. I'm going to change it:

WALKER_NOTES = "${agent_root_folder}/walker_notes.${inputProject}.${PIPELINE_BUILD_NUMBER}.txt"

Thanks Manuele for your feedback! 1. I think it's more useful to have the component name specified in the filename rather than the build number: in this way is more easily to identify the component to which it refers. 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"` 2. you're absolutely right. I'm going to change it: `WALKER_NOTES = "${agent_root_folder}/walker_notes.${inputProject}.${PIPELINE_BUILD_NUMBER}.txt"`

Thanks Manuele for your feedback!

  1. I think it's more useful to have the component name specified in the filename rather than the build number: in this way is more easily to identify the component to which it refers.
    In order to preserve an unique filename as you suggest, I can add to the current filename, the PIPELINE_BUILD_NUMBER.

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.

WALKER_NOTES = "${agent_root_folder}/walker_notes.${inputProject}.${PIPELINE_BUILD_NUMBER}.md"

  1. you're absolutely right. I'm going to change it:

WALKER_NOTES = "${agent_root_folder}/walker_notes.${inputProject}.${PIPELINE_BUILD_NUMBER}.txt"

> Thanks Manuele for your feedback! > > 1. I think it's more useful to have the component name specified in the filename rather than the build number: in this way is more easily to identify the component to which it refers. > In order to preserve an unique filename as you suggest, I can add to the current filename, the `PIPELINE_BUILD_NUMBER`. 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. > > `WALKER_NOTES = "${agent_root_folder}/walker_notes.${inputProject}.${PIPELINE_BUILD_NUMBER}.md"` > > 2. you're absolutely right. I'm going to change it: > > `WALKER_NOTES = "${agent_root_folder}/walker_notes.${inputProject}.${PIPELINE_BUILD_NUMBER}.txt"`

Thanks Manuele for your feedback!

  1. I think it's more useful to have the component name specified in the filename rather than the build number: in this way is more easily to identify the component to which it refers.
    In order to preserve an unique filename as you suggest, I can add to the current filename, the PIPELINE_BUILD_NUMBER.

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.

OK I'm going to remove the component name from the filename

> > Thanks Manuele for your feedback! > > > > 1. I think it's more useful to have the component name specified in the filename rather than the build number: in this way is more easily to identify the component to which it refers. > > In order to preserve an unique filename as you suggest, I can add to the current filename, the `PIPELINE_BUILD_NUMBER`. > > 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. OK I'm going to remove the component name from the filename
}
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}")