fix: make ssh-agent teardown best-effort - #284
Merged
ogulcanaydogan merged 1 commit intoJul 20, 2026
Merged
Conversation
Stopping the agent runs ssh-agent -k during teardown. If the agent process was already gone, for example killed during a long build, the non-zero exit threw an AbortException that failed an otherwise successful build. Log the failure instead of throwing so cleanup is best-effort, and add a test that stops the agent from inside the sshagent block and asserts the build still succeeds. Fixes jenkinsci#230 Signed-off-by: Ogulcan Aydogan <[email protected]>
jglick
reviewed
Jul 29, 2026
| + "}\n", true) | ||
| ); | ||
| WorkflowRun run = story.j.assertBuildStatusSuccess(job.scheduleBuild2(0)); | ||
| story.j.assertLogContains("Failed to run ssh-agent -k", run); |
Member
There was a problem hiding this comment.
@ogulcanaydogan could you disable this test please, unless there is some straightforward way to detect the sort of environment in which it can pass?
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.
Stopping the agent runs
ssh-agent -kduring teardown. If the agent process was already gone (for example killed during a long build), the non-zero exit threw anAbortExceptionthat failed an otherwise successful build (JENKINS-43716).This logs the failure instead of throwing, so teardown is best-effort. The message still includes the exit code and stderr, so a genuine problem is still visible in the build log.
Testing
Added
teardownDoesNotFailBuildWhenAgentAlreadyStoppedtoSSHAgentStepWorkflowTest: it stops the agent from inside thesshagentblock, so the automatic teardown finds it already gone, and asserts the build still succeeds and the failure is logged. Without the change the build fails on teardown.mvn test -Dtest=SSHAgentStepWorkflowTest#teardownDoesNotFailBuildWhenAgentAlreadyStopped,ExecRemoteAgentFailureMessageTestpasses.Fixes #230