From bf13d5e913459224f3590ed53579d927e660c9c7 Mon Sep 17 00:00:00 2001 From: Afonso Mukai <28659574+amues@users.noreply.github.com> Date: Mon, 25 Jun 2018 20:09:32 +0200 Subject: [PATCH] Add release information to artefact (#85) * Add file with build information to artefacts * Escape characters * Try more escaping * Separate getting git commit from printing it * Fix command that was copied from other Jenkinsfile * Fix BUILD_INFO commands --- Jenkinsfile | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 07b24c859..85ddc9a28 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -181,6 +181,13 @@ def docker_tests_coverage(image_key) { def docker_archive(image_key) { def custom_sh = images[image_key]['sh'] + git_commit = sh( + script: """docker exec ${container_name(image_key)} ${custom_sh} -c \" + cd ${project} && git rev-parse HEAD + \"""", + returnStdout: true + ).trim() + sh """docker exec ${container_name(image_key)} ${custom_sh} -c \" mkdir -p archive/event-formation-unit && \ cp -r ${project}/build/bin archive/event-formation-unit && \ @@ -195,10 +202,17 @@ def docker_archive(image_key) { cp -r ${project}/prototype2/multigrid/calib_data/* archive/event-formation-unit/data && \ cd archive && \ tar czvf event-formation-unit-centos7.tar.gz event-formation-unit + + # Create file with build information + touch BUILD_INFO + echo 'Repository: ${project}/${env.BRANCH_NAME}' >> BUILD_INFO + echo 'Commit: ${git_commit}' >> BUILD_INFO + echo 'Jenkins build: ${BUILD_NUMBER}' >> BUILD_INFO \"""" sh "docker cp ${container_name(image_key)}:/home/jenkins/archive/event-formation-unit-centos7.tar.gz ." - archiveArtifacts "event-formation-unit-centos7.tar.gz" + sh "docker cp ${container_name(image_key)}:/home/jenkins/archive/BUILD_INFO ." + archiveArtifacts "event-formation-unit-centos7.tar.gz,BUILD_INFO" } def get_pipeline(image_key) @@ -208,7 +222,7 @@ def get_pipeline(image_key) node ("docker") { try { def container = get_container(image_key) - + docker_clone(image_key) if (image_key != clangformat_os) { docker_dependencies(image_key) @@ -219,7 +233,7 @@ def get_pipeline(image_key) if (image_key == coverage_on) { docker_tests_coverage(image_key) } else if (image_key == clangformat_os) { - + } else { docker_tests(image_key) } @@ -227,7 +241,7 @@ def get_pipeline(image_key) if (image_key == archive_what) { docker_archive(image_key) } - + if (image_key == clangformat_os) { docker_cppcheck(image_key) step([$class: 'WarningsPublisher', parserConfigurations: [[parserName: 'Cppcheck Parser', pattern: "cppcheck.txt"]]])