diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 7f5fca536b5461d087f458e9f5718615bb1d4b2b..feec019e5df158c7cf4860ad1915a55cec8474a8 100755 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -71,7 +71,11 @@ pipeline { steps { sh "mkdir -p ${YASHCHIKI_META_DIR}" sh "bash bin/yashchiki_dump_meta_info.sh" - sh "bash bin/yashchiki_notify_gerrit.sh -m 'Build containing this change started..'" + script { + if (isTriggeredByGerrit()) { + sh "bash bin/yashchiki_notify_gerrit.sh -m 'Build containing this change started..'" + } + } } } stage('Deploy utilities') { @@ -109,8 +113,10 @@ pipeline { script { // we only want the container name, tail everything else CONTAINER_IMAGE = sh(script: "bash bin/yashchiki_deploy_container.sh | tail -n 1", returnStdout: true).trim() + if (isTriggeredByGerrit()) { + sh "bash bin/yashchiki_notify_gerrit.sh -t Build -c \"$CONTAINER_IMAGE\"" + } } - sh "bash bin/yashchiki_notify_gerrit.sh -t Build -c \"$CONTAINER_IMAGE\"" } } } @@ -118,8 +124,10 @@ pipeline { failure { script { cache_failed = sh(script: "bash lib/yashchiki/create_temporary_build_cache_after_failure.sh", returnStdout: true).trim() + if (isTriggeredByGerrit()) { + sh "bash bin/yashchiki_notify_gerrit.sh -v -1 -t Build -m \"Successfully built packages stored in cache. Resume by issuing:\nWITH_CACHE_NAME=${cache_failed}\n\nIn your next gerrit comment, NOT commit message!\"" + } } - sh "bash bin/yashchiki_notify_gerrit.sh -v -1 -t Build -m \"Successfully built packages stored in cache. Resume by issuing:\nWITH_CACHE_NAME=${cache_failed}\n\nIn your next gerrit comment, NOT commit message!\"" } cleanup { archiveArtifacts "host.env" @@ -189,13 +197,25 @@ pipeline { } post { success { - jesh "bash bin/yashchiki_notify_gerrit.sh -v 1 -t Tests -c '${CONTAINER_IMAGE}'" + script { + if (isTriggeredByGerrit()) { + jesh "bash bin/yashchiki_notify_gerrit.sh -v 1 -t Tests -c '${CONTAINER_IMAGE}'" + } + } } unstable { - jesh "bash bin/yashchiki_notify_gerrit.sh -v 0 -t Tests -c '${CONTAINER_IMAGE}'" + script { + if (isTriggeredByGerrit()) { + jesh "bash bin/yashchiki_notify_gerrit.sh -v 0 -t Tests -c '${CONTAINER_IMAGE}'" + } + } } failure { - jesh "bash bin/yashchiki_notify_gerrit.sh -v -1 -t Tests -c '${CONTAINER_IMAGE}'" + script { + if (isTriggeredByGerrit()) { + jesh "bash bin/yashchiki_notify_gerrit.sh -v -1 -t Tests -c '${CONTAINER_IMAGE}'" + } + } } } } diff --git a/.ci/Jenkinsfile_asic b/.ci/Jenkinsfile_asic index b38dda96f482ceddcc7fb31234bda896ecd52b18..84edfcb425980ac2070f3feba5ae1f17a3859d7e 100755 --- a/.ci/Jenkinsfile_asic +++ b/.ci/Jenkinsfile_asic @@ -77,7 +77,11 @@ pipeline { steps { sh "mkdir -p ${YASHCHIKI_META_DIR}" sh "bash bin/yashchiki_dump_meta_info.sh" - sh "bash bin/yashchiki_notify_gerrit.sh -m 'Build containing this change started..'" + script { + if (isTriggeredByGerrit()) { + sh "bash bin/yashchiki_notify_gerrit.sh -m 'Build containing this change started..'" + } + } } } stage('Build container image') { @@ -110,8 +114,10 @@ pipeline { script { // we only want the container name, tail everything else CONTAINER_IMAGE = sh(script: "bin/yashchiki_deploy_container.sh | tail -n 1", returnStdout: true).trim() + if (isTriggeredByGerrit()) { + sh "bash bin/yashchiki_notify_gerrit.sh -t Build -c \"$CONTAINER_IMAGE\"" + } } - sh "bash bin/yashchiki_notify_gerrit.sh -t Build -c \"$CONTAINER_IMAGE\"" } } } @@ -119,8 +125,10 @@ pipeline { failure { script { cache_failed = sh(script: "lib/yashchiki/create_temporary_build_cache_after_failure.sh", returnStdout: true).trim() + if (isTriggeredByGerrit()) { + sh "bash bin/yashchiki_notify_gerrit.sh -v -1 -t Build -m \"Successfully built packages stored in cache. Resume by issuing:\nWITH_CACHE_NAME=${cache_failed}\n\nIn your next gerrit comment, NOT commit message!\"" + } } - sh "bash bin/yashchiki_notify_gerrit.sh -v -1 -t Build -m \"Successfully built packages stored in cache. Resume by issuing:\nWITH_CACHE_NAME=${cache_failed}\n\nIn your next gerrit comment, NOT commit message!\"" } cleanup { archiveArtifacts "host.env" diff --git a/bin/yashchiki_notify_gerrit.sh b/bin/yashchiki_notify_gerrit.sh index 8cbe558203b83a262e06d0446d7bbccedfda9794..78ad069ee7865a3bd1fa9cb3eb2f888575a4ca3d 100755 --- a/bin/yashchiki_notify_gerrit.sh +++ b/bin/yashchiki_notify_gerrit.sh @@ -16,8 +16,7 @@ if ! [ "${CONTAINER_BUILD_TYPE:-}" = "testing" ]; then fi ROOT_DIR="$(dirname "$(dirname "$(readlink -m "${BASH_SOURCE[0]}")")")" -source "${ROOT_DIR}/lib/yashchiki/dummy_variables.sh" -source "${ROOT_DIR}/lib/yashchiki/commons.sh" +source "${ROOT_DIR}/lib/yashchiki/gerrit.sh" container_name="" result_type="" @@ -54,7 +53,7 @@ if [ -z "${result}" ] && [ -n "${verified}" ]; then fi fi -message="[$(get_host_env BUILD_URL)] \ +message="[$(echo "${BUILD_URL}")] \ ${container_name:+Change included in container: ${container_name}} \ ${custom_message:-} \ ${result:+${result_type:+${result_type} }Result: ${result}}" @@ -65,26 +64,19 @@ if [ "${CONTAINER_BUILD_TYPE}" = "testing" ]; then # Notify all changes involved that they got built into the current container # yashchiki changes - meta_dir="$(get_var_in_out META_DIR)" - if [ -f "${meta_dir}/current_changes-yashchiki.dat" ]; then - cat "${meta_dir}/current_changes-yashchiki.dat" >> "${tmpfile_commits}" + if [ -f "${YASHCHIKI_META_DIR}/current_changes-yashchiki.dat" ]; then + cat "${YASHCHIKI_META_DIR}/current_changes-yashchiki.dat" >> "${tmpfile_commits}" fi # spack changes - if [ -f "${meta_dir}/current_changes-spack.dat" ]; then - cat "${meta_dir}/current_changes-spack.dat" >> "${tmpfile_commits}" + if [ -f "${YASHCHIKI_META_DIR}/current_changes-spack.dat" ]; then + cat "${YASHCHIKI_META_DIR}/current_changes-spack.dat" >> "${tmpfile_commits}" fi readarray -t commits < <(grep -v "^$" "${tmpfile_commits}") - # if we are in a singularity container we need to go to the spack - # repository so the gerrit notifier can extract gerrit settings all - if [ -n "${SINGULARITY_CONTAINER:-}" ]; then - pushd "${MY_SPACK_FOLDER}" &>/dev/null || exit 1 - fi - # needs to be in git repo for gerrit_notify_change to work - cd ${WORKSPACE}/yashchiki + cd ${YASHCHIKI_INSTALL} for change in "${commits[@]}"; do if ! gerrit_notify_change -c "${change}" \ -v "${verified}" \ @@ -93,9 +85,5 @@ if [ "${CONTAINER_BUILD_TYPE}" = "testing" ]; then fi done - if [ -n "${SINGULARITY_CONTAINER:-}" ]; then - popd &>/dev/null || exit 1 - fi - rm -v "${tmpfile_commits}" 1>&2 fi