]> git.apps.os.sepia.ceph.com Git - ceph-build.git/commitdiff
ceph-dev-pipeline: Add and use update_shaman.sh
authorZack Cerza <zack@cerza.org>
Tue, 29 Apr 2025 00:05:04 +0000 (18:05 -0600)
committerZack Cerza <zack@cerza.org>
Wed, 7 May 2025 23:28:45 +0000 (17:28 -0600)
Signed-off-by: Zack Cerza <zack@cerza.org>
ceph-dev-pipeline/build/Jenkinsfile
scripts/update_shaman.sh [new file with mode: 0755]

index 89ba943d39a60ce779602f176583d9289f22b105..19f175d61753547e0a96725e33733f6fdcf324f2 100644 (file)
@@ -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 (executable)
index 0000000..3ad2e02
--- /dev/null
@@ -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