]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-build.git/commitdiff
update_shaman: Send pipeline matrix URL when updating shaman build url 2584/head
authorDavid Galloway <david.galloway@ibm.com>
Fri, 17 Jul 2026 17:24:08 +0000 (13:24 -0400)
committerDavid Galloway <david.galloway@ibm.com>
Fri, 17 Jul 2026 17:24:08 +0000 (13:24 -0400)
Fixes: https://tracker.ceph.com/issues/72370
Signed-off-by: David Galloway <david.galloway@ibm.com>
scripts/update_shaman.sh

index aef433e31fc9e6ddc0b551cbcaf86132afeba2ae..5f50b5c0e66e5f506e575768f6f5e227e1d1a5fd 100755 (executable)
@@ -1,17 +1,65 @@
 #!/bin/bash
 # vim: ts=4 sw=4 expandtab
 
-submit_build_status() {
+get_pipeline_node_url() {
+    local distro="$1"
+    local arch="$2"
+    local flavor="${FLAVOR:-default}"
+
+    # cut is portable; no sed regex quirks
+    local base job build_num
+    base=$(echo "$BUILD_URL"      | cut -d/ -f1-3)    # https://jenkins.ceph.com
+    job=$(echo "$BUILD_URL"       | cut -d/ -f5)      # ceph-dev-pipeline
+    build_num=$(echo "$BUILD_URL" | cut -d/ -f6)      # 5306
+
+    local nodes_json branch_id child_id
+
+    # By default, the Blue Ocean nodes API returns a limited number of nodes.  We have at around 160
+    # as of this writing so `limit=500` bypasses that limitation.
+    # Store the node IDs used for this particular job.
+    nodes_json=$(curl -sf \
+        "${base}/blue/rest/organizations/jenkins/pipelines/${job}/runs/${build_num}/nodes/?limit=500" \
+        2>/dev/null)
+
+    # This is the branch of the matrix.. not a git branch.
+    branch_id=$(echo "$nodes_json" | jq -r \
+        --arg dist "$distro" --arg arch "$arch" --arg flav "$flavor" \
+        '[.[] | select(.displayName | (contains($dist) and contains($arch) and contains($flav)))] | first | .id // empty')
+
+    # Now find the node ID (the Jenkins builder ID) used for this particular matrix branch.
+    child_id=$(echo "$nodes_json" | jq -r \
+        --arg parent "$branch_id" \
+        '[.[] | select(.firstParent == $parent)] | first | .id // empty')
+
+    # Fall back to the branch ID if we couldn't get a node ID.
+    local node_id="${child_id:-${branch_id}}"
 
-    # 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
+    if [ -n "$node_id" ]; then
+        echo "${BUILD_URL}pipeline-overview/?selected-node=${node_id}"
+    else
+        echo "$BUILD_URL"
+    fi
+}
+
+submit_build_status() {
     http_method=$1
     state=$2
     project=$3
     distro=$4
     distro_version=$5
     distro_arch=$6
+
+    local pipeline_url log_url
+    pipeline_url=$(get_pipeline_node_url "$distro" "$distro_arch")
+
+    # If we were able to deduce an individual matrix branch node ID,
+    # use that for log_url, else use the older consoleFull endpoint.
+    if [[ $pipeline_url =~ selected-node ]]; then
+        log_url="$pipeline_url"
+    else
+        log_url="$BUILD_URL/consoleFull"
+    fi
+
     cat > $WORKSPACE/build_status.json << EOF
 {
     "extra":{
@@ -22,7 +70,7 @@ submit_build_status() {
         "build_user":"$BUILD_USER"
     },
     "url":"$BUILD_URL",
-    "log_url":"$BUILD_URL/consoleFull",
+    "log_url":"$log_url",
     "status":"$state",
     "distro":"$distro",
     "distro_version":"$distro_version",