Skip to content

Commit

Permalink
Add release information to artefact (#85)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
amues authored Jun 25, 2018
1 parent c1c5e66 commit bf13d5e
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -219,15 +233,15 @@ 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)
}

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"]]])
Expand Down

0 comments on commit bf13d5e

Please sign in to comment.