Format stdout report as XML. Attach it to the email.

This commit is contained in:
Manuele Simi 2021-01-31 22:04:11 -05:00
parent e9369099fb
commit 446721255b
1 changed files with 14 additions and 9 deletions

23
Jenkinsfile vendored
View File

@ -34,7 +34,7 @@ pipeline {
AGENT_ROOT_FOLDER = "${agent_root_folder}"
PIPELINE_BUILD_NUMBER = "${env.BUILD_NUMBER}"
ACTION_REPORT = "${agent_root_folder}/actions.${env.BUILD_NUMBER}.csv"
ACTION_OUTPUT = "${agent_root_folder}/action-output.${env.BUILD_NUMBER}.txt"
ACTION_OUTPUT = "${agent_root_folder}/action-output.${env.BUILD_NUMBER}.xml"
ACTION_URL="${actionURL}"
REPO_ROOT="${git_root}"
@ -66,6 +66,8 @@ pipeline {
echo "#Build ${PIPELINE_BUILD_NUMBER},," > $ACTION_REPORT
echo "#StartTime ${date},," >> $ACTION_REPORT
echo "Project,Repo,Result" >> $ACTION_REPORT
sh "echo -e '<actions from="${ACTION_URL}">' > $ACTION_OUTPUT"
'''
}
}
@ -79,6 +81,7 @@ pipeline {
sh "echo -e ${projects[i]},${git_root}/${projects[i]},Completed >> $ACTION_REPORT"
}
}
sh "echo -e '</actions>'>> $ACTION_OUTPUT"
}
}
}
@ -89,17 +92,17 @@ pipeline {
always {
script {
sh '''
cp $ACTION_REPORT ./actions.${PIPELINE_BUILD_NUMBER}.csv
cat ./actions.${PIPELINE_BUILD_NUMBER}.csv
cp $ACTION_OUTPUT ./action-output.${PIPELINE_BUILD_NUMBER}.txt
cat ./action-output.${PIPELINE_BUILD_NUMBER}.txt
cp $ACTION_REPORT ./action.${PIPELINE_BUILD_NUMBER}.csv
cat ./action.${PIPELINE_BUILD_NUMBER}.csv
cp $ACTION_OUTPUT ./action-output.${PIPELINE_BUILD_NUMBER}.xml
cat ./action-output.${PIPELINE_BUILD_NUMBER}.xml
'''
}
}
success {
echo 'The actions pipeline worked!'
emailext attachmentsPattern: "**/actions.${env.BUILD_NUMBER}.csv",
emailext attachmentsPattern: "**/action*${env.BUILD_NUMBER}.*",
to: 'manuele.simi@isti.cnr.it',
subject: "Actions report(build #${PIPELINE_BUILD_NUMBER})",
body: "${currentBuild.fullDisplayName}. Build time: ${currentBuild.durationString}. See ${env.BUILD_URL}"
@ -172,12 +175,14 @@ def exec(repo_url, repo_name) {
rm actions.sh
git push --force origin HEAD:master || true
"""
output = sh(script: bashWrapper, returnStdout: true)
output = sh(script: bashWrapper, returnStdout: true)?.trim()
}
}
sh "echo -e --- STDOUT FROM REPO ${repo_url} --- >> $ACTION_OUTPUT"
sh "echo -e '<action repo="${repo_url}">"' --- >> $ACTION_OUTPUT"
sh "echo -e '<stdout>' >> $ACTION_OUTPUT"
sh "echo -e '${output}' >> $ACTION_OUTPUT"
sh "echo -e --- END REPO ${repo_url} --- >> $ACTION_OUTPUT"
sh "echo -e '</stdout>' >> $ACTION_OUTPUT"
sh "echo -e '</action>' --- >> $ACTION_OUTPUT"
}