From: Zack Cerza Date: Tue, 29 Apr 2025 00:05:04 +0000 (-0600) Subject: ceph-dev-pipeline: Add and use update_shaman.sh X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=c8e5d0cc36c977a29be03130b09b336c8c8b02c4;p=ceph-build.git ceph-dev-pipeline: Add and use update_shaman.sh Signed-off-by: Zack Cerza --- diff --git a/ceph-dev-pipeline/build/Jenkinsfile b/ceph-dev-pipeline/build/Jenkinsfile index 89ba943d..19f175d6 100644 --- a/ceph-dev-pipeline/build/Jenkinsfile +++ b/ceph-dev-pipeline/build/Jenkinsfile @@ -339,10 +339,7 @@ pipeline { steps { script { def os = get_os_info(env.DIST) - sh """#!/bin/bash - . ./scripts/build_utils.sh - update_build_status "started" "ceph" ${os.name} ${os.version_name} $ARCH - """ + sh "./scripts/update_shaman.sh started ceph ${os.name} ${os.version_name} $ARCH" env.AWS_ACCESS_KEY_ID = env.SCCACHE_BUCKET_CREDS_USR env.AWS_SECRET_ACCESS_KEY = env.SCCACHE_BUCKET_CREDS_PSW sh 'echo > .env' @@ -455,19 +452,13 @@ pipeline { export OS_PKG_TYPE="${os.pkg_type}" if [ "$THROWAWAY" != "true" ]; then ./scripts/chacra_upload.sh; fi """ - sh """#!/bin/bash - . ./scripts/build_utils.sh - update_build_status "completed" "ceph" ${os.name} ${os.version_name} $ARCH - """ + sh "./scripts/update_shaman.sh completed ceph ${os.name} ${os.version_name} $ARCH" } } unsuccessful { script { def os = get_os_info(env.DIST) - sh """#!/bin/bash - . ./scripts/build_utils.sh - update_build_status "failed" "ceph" ${os.name} ${os.version_name} $ARCH - """ + sh "./scripts/update_shaman.sh failed ceph ${os.name} ${os.version_name} $ARCH" } } } diff --git a/scripts/update_shaman.sh b/scripts/update_shaman.sh new file mode 100755 index 00000000..3ad2e02b --- /dev/null +++ b/scripts/update_shaman.sh @@ -0,0 +1,51 @@ +submit_build_status() { + + # A helper script to post (create) the status of a build in shaman + # 'state' can be either 'failed' or 'started' + # 'project' is used to post to the right url in shaman + http_method=$1 + state=$2 + project=$3 + distro=$4 + distro_version=$5 + distro_arch=$6 + cat > $WORKSPACE/build_status.json << EOF +{ + "extra":{ + "version":"$vers", + "root_build_cause":"$ROOT_BUILD_CAUSE", + "node_name":"$NODE_NAME", + "job_name":"$JOB_NAME", + "build_user":"$BUILD_USER" + }, + "url":"$BUILD_URL", + "log_url":"$BUILD_URL/consoleFull", + "status":"$state", + "distro":"$distro", + "distro_version":"$distro_version", + "distro_arch":"$distro_arch", + "ref":"$BRANCH", + "sha1":"$SHA1", + "flavor":"$FLAVOR" +} +EOF + + # these variables are saved in this jenkins + # properties file so that other scripts + # in the same job can inject them + cat > $WORKSPACE/build_info << EOF +NORMAL_DISTRO=$distro +NORMAL_DISTRO_VERSION=$distro_version +NORMAL_ARCH=$distro_arch +SHA1=$SHA1 +EOF + + SHAMAN_URL="https://shaman.ceph.com/api/builds/$project/" + # post the build information as JSON to shaman + curl -X $http_method -H "Content-Type:application/json" --data "@$WORKSPACE/build_status.json" -u $SHAMAN_API_USER:$SHAMAN_API_KEY ${SHAMAN_URL} +} + +# If the script is executed (as opposed to sourced), run the function now +if [ "$(basename -- "${0#-}")" = "$(basename -- "${BASH_SOURCE}")" ]; then + submit_build_status "POST" "$@" +fi