diff --git a/Jenkinsfile b/Jenkinsfile index 313d2ff..f610b36 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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 '' > $ACTION_OUTPUT" + ''' } } @@ -79,6 +81,7 @@ pipeline { sh "echo -e ${projects[i]},${git_root}/${projects[i]},Completed >> $ACTION_REPORT" } } + sh "echo -e ''>> $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_OUTPUT" + sh "echo -e '' >> $ACTION_OUTPUT" sh "echo -e '${output}' >> $ACTION_OUTPUT" - sh "echo -e --- END REPO ${repo_url} --- >> $ACTION_OUTPUT" + sh "echo -e '' >> $ACTION_OUTPUT" + sh "echo -e '' --- >> $ACTION_OUTPUT" }