jenkinsci / jenkinsci/branch-api-plugin

[JENKINS-60785] corrupt workspaces.txt file on agent, changes multibranch builds to use workspace directory with slash converted to %2F, causing errors

Open
#737 3 comments 0 reactions 0 assignees View on GitHub
component:branch-api-plugin imported-jira-issue priority:major resolution:unresolved robustness
Dominant language
Java
Stars
39
Forks
154
PR merge metrics
No merged PRs in 30d

Description

I'm facing the same problem with my multibranch pipeline project: "feature/branch" from a git repository is transformed to "feature%2Fbranch" which causes build to fail because the build process cannot find the files. Agents  aredoing the building. In my case interestingly this was only happening on 1 of three nodes (it took me hours to figure THAT out).

After much searching what I found was that when I reviewed the node log for the failing node (Manage Jenkins -> Manage Nodes -> click on node in question -> Log, I found that the /home/jenkins/workspace/workspace.txt file was noted as being corrupt.  For whatever reason this meant that when the build was attempted on that node, the build directory was not the usual workspace directory (which has all branch name slashes (encoded as %2F) cases  replaced with underscores).

In my case, I just created a new workspace.txt file and then disconnected and reconnected the node.  And... things started working again.

So, if you're experiencing this, review the node logs.  

As a suggestion for improving jenkins, I would suggest that if the workspaces.txt file is corrupt, the node should be taken offline.  At least then the admin has a clue that this is a node based issue, and that the node needs manual intervention for things to get back to normal.

From jglick,

"Of course better would be to automatically correct a corrupted file, and better still would be to figure out what corrupted it to begin with. What did the supposedly corrupt file contain?"

I've attached the corrupted workspaces.txt file. It looks like it was cut off mid way through writing a branch name.  Perhaps variable overrun, or an uncerimonious shut down created this issue.

---
Originally reported by jrichards, imported from: corrupt workspaces.txt file on agent, changes multibranch builds to use workspace directory with slash converted to %2F, causing errors


  • status: Open
  • priority: Major
  • component(s): branch-api-plugin
  • label(s): robustness
  • resolution: Unresolved
  • votes: 1
  • watchers: 4
  • imported: 20251211-141027

Raw content of original issue

I'm facing the same problem with my multibranch pipeline project: "feature/branch" from a git repository is transformed to "feature%2Fbranch" which causes build to fail because the build process cannot find the files. Agents  aredoing the building. In my case interestingly this was only happening on 1 of three nodes (it took me hours to figure THAT out).

After much searching what I found was that when I reviewed the node log for the failing node (Manage Jenkins -> Manage Nodes -> click on node in question -> Log, I found that the /home/jenkins/workspace/workspace.txt file was noted as being corrupt.  For whatever reason this meant that when the build was attempted on that node, the build directory was not the usual workspace directory (which has all branch name slashes (encoded as %2F) cases  replaced with underscores).

In my case, I just created a new workspace.txt file and then disconnected and reconnected the node.  And... things started working again.

So, if you're experiencing this, review the node logs.  

As a suggestion for improving jenkins, I would suggest that if the workspaces.txt file is corrupt, the node should be taken offline.  At least then the admin has a clue that this is a node based issue, and that the node needs manual intervention for things to get back to normal.

From jglick,

"Of course better would be to automatically correct a corrupted file, and better still would be to figure out what corrupted it to begin with. What did the supposedly corrupt file contain?"

I've attached the corrupted workspaces.txt file. It looks like it was cut off mid way through writing a branch name.  Perhaps variable overrun, or an uncerimonious shut down created this issue.

environment

```
linux, multi-branch pipeline build with agents doing the building.

Jenkins version 2.190.3 Branch API Plugin Version 2.5.5
```

1 attachment

- [workspaces.txt_corrupt](https://issues.jenkins.io/secure/attachment/50000/workspaces.txt_corrupt)

Contributor guide

Open the contributing guide

Research direction

Start by examining the branch-api-plugin handling of an agent's workspaces.txt file and the node log message for corruption. Reproduce the reported truncated-file condition using the attached workspaces.txt_corrupt example; done should include a defined safe response when the file is corrupt, such as correcting it or taking the agent offline.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
infrastructure
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.