Skip to content

Model file-paths at agent computer using FilePath instead of nio.Path - #304

Merged
ogulcanaydogan merged 1 commit into
jenkinsci:masterfrom
HannesWell:agent-file-path-as-FilePath
Aug 19, 2026
Merged

Model file-paths at agent computer using FilePath instead of nio.Path#304
ogulcanaydogan merged 1 commit into
jenkinsci:masterfrom
HannesWell:agent-file-path-as-FilePath

Conversation

@HannesWell

Copy link
Copy Markdown
Contributor

When using java.nio.file.Path, the OS and file-system of the controller is used, but the model paths in fact refer to the file-system of and files at the executing agent computer.
In case of an OS mismatch between controller and agent, this can lead to parsing errors and incorrect environments.
E.g. the Linux implementation of java.nio.file.Path cannot handle Windows style paths and usually throws an Exception in that case.

By using (remote) hudson.FilePath instead the OS/file-system of the executing agent computer is considered.

Furthermore, use the File separator of file-system at the agent computer, not the controller's.

Follow-up on

Testing done

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

@ogulcanaydogan

ogulcanaydogan commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Good catch, the controller-vs-agent filesystem mismatch is a real bug and switching to FilePath is the right fix, thanks for scoping this out as its own small PR instead of bundling it into #169, makes it much easier to review.

Heads up on timing: I have #306 open (CI running now) which touches this exact method (toSSHAgentPath) for a different bug, empty-string executable from a blank UI field crashing legacy job configs. It only adds one condition to the null-check, so once it merges this should be a trivial rebase, but you'll likely see a small conflict on that line. Happy to handle the rebase myself if that's easier for you, just say the word.

@ogulcanaydogan

Copy link
Copy Markdown
Contributor

Since I'm the one who created the conflict by merging #306 first, I went ahead and did the rebase myself rather than leave it on your plate. Pushed it to my own fork, not touching your branch at all: https://github.com/ogulcanaydogan/ssh-agent-plugin/tree/rebase-304-onto-master

It was a one-line conflict exactly where I expected (the null-check in toSSHAgentPath), resolved by keeping your FilePath signature with my blank-string check added in. Full suite green (50/50). Totally fine to ignore this and do your own rebase if you'd rather, just wanted to save you the trouble in case it's useful, happy to open a PR against your branch instead if that's easier than cherry-picking.

When using java.nio.file.Path, the OS and file-system of the controller
is used, but the model paths in fact refer to the file-system of and
files at the executing agent computer.
In case of an OS mismatch between controller and agent, this can lead to
parsing errors and incorrect environments.
E.g. the Linux implementation of java.nio.file.Path cannot handle
Windows style paths and usually throws an Exception in that case.
By using (remote) hudson.FilePath instead the OS/file-system of the
executing agent computer is considered.

Furthermore, use the File separator of file-system at the agent
computer, not the controller's.

Follow-up on
- jenkinsci#296
@HannesWell
HannesWell force-pushed the agent-file-path-as-FilePath branch from fac2805 to 5a407a9 Compare August 18, 2026 18:51
@HannesWell

HannesWell commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

Good catch, the controller-vs-agent filesystem mismatch is a real bug and switching to FilePath is the right fix, thanks for scoping this out as its own small PR instead of bundling it into #169, makes it much easier to review.

Thanks :)

you'll likely see a small conflict on that line. Happy to handle the rebase myself if that's easier for you, just say the word.

No problem, was easy to resolve. Just rebased and pushed the update.
But thanks for helping!

I have #306 open (CI running now) which touches this exact method (toSSHAgentPath) for a different bug, empty-string executable from a blank UI field crashing legacy job configs

There are really a lot of things to consider :O Thanks for fixing that!

@ogulcanaydogan
ogulcanaydogan merged commit eb02517 into jenkinsci:master Aug 19, 2026
18 checks passed
@HannesWell
HannesWell deleted the agent-file-path-as-FilePath branch August 19, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants