Fix Claude analysis gating to handle co-failures correctly#25491
Fix Claude analysis gating to handle co-failures correctly#25491
Conversation
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 32005 | |
| Version | PR #25491 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | c530df9 | |
| Installation URL | 166b11m92fe58 |
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 32005 | |
| Version | PR #25491 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | c530df9 | |
| Installation URL | 333jt4p48oo08 |
The previous script exited early when any non-essential step (e.g. Danger) failed, incorrectly skipping Claude analysis even when essential jobs also failed in the same build. Now counts non-essential failures first, then queries the Buildkite API for the total failed job count. Claude is only skipped when all failures are accounted for by non-essential steps. Fails safe: if the API call fails, Claude runs anyway. Also fixes shebang portability, uses a proper Bash array for step keys, uses YAML literal scalar to preserve prompt formatting, and includes timed_out jobs in the failure count. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Two bugs fixed: - buildkite-agent step get outcome returns "hard_failed", not "failed", so the non-essential check never matched - When all steps passed, the script fell through to uploading Claude analysis instead of exiting early Also restructures the script to query the API first, which simplifies the flow and avoids a redundant early-exit branch. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
683f6ca to
c530df9
Compare
mokagio
left a comment
There was a problem hiding this comment.
@iangmaia great job on this update across the apps.
Have you considered a next step where the script goes into CI toolkit with a default array of non-essential jobs comprising of Danger and SwiftLint, and the option for consumers to define a file in the repo (.buildkite/claude-analysis-non-essential-steps?) or an overriding env var in shared-pipeline-vars?
That's not a bad idea! Though the Claude Build Analysis is probably going to change to adopt Buildkite Model Providers or a different solution given the plugin has been deprecated. As is, it is still interesting and we can likely migrate to other setup taking the learnings we had so far, but I wouldn't invest in tweaking the current setup that much. |
Good point, good point. I also wonder if this is actually useful for folks? Do you have any feedback on it? But even then, AI analysis annotations might not be useful for devs but could be useful for us to get to a place where they can be useful? So definitely worth to keep investing on this, the question is how to measure usefulness/effectiveness. |
Yep, I'm still seeing it as an experiment. I often check it, sometimes it has useful insights, but often it is just noisy and verbose, runs when it shouldn't, etc so these changes are important to make it more reliable and relevant. The next iterations (hopefully already in a custom and more compact template) should keep improving it. |


Description
Follow-up to #25477. Fixes a logic bug in
upload-claude-analysis.shwhere the script exited early on the first non-essential failure (e.g. Danger), causing Claude analysis to be silently skipped even when essential jobs also failed in the same build.Changes:
non_essential_failures == total_failures.#!/bin/bash -eu→#!/usr/bin/env bash+set -eufor portability.NON_ESSENTIAL_STEPSis now a proper array to avoid word splitting/glob issues.custom_prompt: >→custom_prompt: |to preserve numbered list and paragraph structure.failedandtimed_outjob states.Test Steps
RELEASE-NOTES.txtif necessary.