Repository navigation
feat: Copy a failed build for a coding agent, with no AI provider needed - #264
Open
shenxianpeng wants to merge 1 commit into
Open
shenxianpeng wants to merge 1 commit into
shenxianpeng wants to merge 1 commit into
Conversation
The console page gets Copy for AI agent: the failure written up for Claude Code, Codex or another coding agent, with the repository, branch, commit and pull request, the log of the failing steps, the explanation the build has, and what to do, secrets masked. No provider is called, so it works as soon as the plugin is installed, for anyone who can read the build. Where the clipboard is not available the text opens in a dialog. Step headers now name the stage and the command the step ran.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Coding agents such as Claude Code and Codex can fix what an explanation only describes: they work in a checkout of the repository, read the code and run the command that failed. What they lack is the failure, which is in Jenkins, often behind a login or on a network the agent cannot reach. Pasting a build link does not help there, and copying a raw console of thousands of lines is noisy and leaks secrets.
This adds Copy for AI agent to the console page of a failed build. It copies the failure written up for an agent:
Secrets are masked first, as for the provider. No AI provider is called, so the button works as soon as the plugin is installed, with no provider and no key, for anyone with Item/Read, and uses no quota. The global Enable AI Error Explanation and a folder's Turn off AI error explanation turn it off as well. The endpoint (
console-explain-error/agentContext) is POST with the crumb; a GET gets 405. Where the browser does not let the page write to the clipboard (a Jenkins served over plain HTTP, or a refused permission), the text opens in a dialog with a Copy button.The step header the extractor writes now names the stage (and parallel branch) and the command the step ran (
shscript,errormessage; ten lines at most, without the Jenkinsfile's indentation). The agent needs it to reproduce the failure, and the AI explanation gets it too.Before / After
No provider configured, console page:
The text, in the dialog shown where the clipboard is not available:
Provider configured:
End to end, on a local Jenkins with no provider: a Pipeline from a Git repository runs
python3 -m unittest, andorder_total()skips the first item (items[1:]). The copied text named the repository, branchmain, the commit, stageTest, the command, both failing assertions, and masked theAPI_TOKENechoed by the script (3 places). Pasted as is into Claude Code in a clone at that commit, it founditems[1:], changed it toitems, and ran the tests: 2 failures before, OK after.Testing done
AgentContextTest(10): a failed Pipeline without a provider (stage, command without indentation, log, masking, absolute build URL), repository/branch/commit from the Git plugin's checkout record and the pull request from the multibranch variables, the build's explanation, a log with backticks that cannot close its code block, permissions (Item/Read can, without it cannot, GET refused), explanation turned off (403, no button), the console page without a provider (only Copy for AI agent; the dialog with the text, as HtmlUnit has no clipboard), with a provider (both buttons in the console toolbar), indentation removal, branch names without their remote.mvn verify(JDK 21): 1,068 tests, 0 failures after updating 4 assertions to the new behaviour (a reader now gets the agent button; the step header names the command, so the masked count rises from 2 to 4 and the log-pattern check looks at the log lines); SpotBugs 0 bugs.Submitter checklist
Was generative AI tooling used to co-author this PR?