jenkinsci / jenkinsci/branch-api-plugin

[JENKINS-60969] @libs pseudo-workspace collision due to branch name truncation

Open
#740 15 comments 0 reactions 0 assignees View on GitHub
component:branch-api-plugin component:pipeline-groovy-lib-plugin imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
39
Forks
154
PR merge metrics
No merged PRs in 30d

Description

I've spot an issue with unwanted interaction between different, independent jobs.

Here are the details: Our Jenkins instance (2.176.1 LTS) has some global pipeline libraries configured. My task was some kind of structural migration on a bunch of different projects. So I created a corresponding branch on each of these projects, did the change there and pushed it. So all the build jobs started at the same time and surprisingly most of them failed with a strange error during initial jobs steps like this:

...

remote: Compressing objects: 100% (6/6), done.
remote: Total 8 (delta 0), reused 0 (delta 0)
error: cannot lock ref 'refs/remotes/origin/bugfix/ESTA-3146-yla': Unable to create '/var/jenkins_home/workspace/rate-build-description-to-json_5@​libs/pipeline-helper/.git/refs/remotes/origin/bugfix/ESTA-3146-yla.lock': File exists.

Another git process seems to be running in this repository, e.g.
...


After digging around I figured out, that the pipeline helper libs are cloned on the Jenkins master using a folder named like the job a/o branch, which is suffixed with `_@​libs`. Additionally the folder name is stripped to 37 characters by removing characters from the beginning of the name. This leads to the real cause: Because of the identical branch name on each Git repository, the unique part of the folder names got lost and so the jobs try to use the same folder during their initialization steps respectively the cloning of the pipeline helper libs. As soon as the simultaneous running jobs have a differnt build number, it works as expected.

The branch was named "feature/KIHUB-7882-separate-build-description-to-json" on all modified projects respectively Git repositories and so at the master it looks like this right now:

$ cd /var/jenkins_home/workspace

$ ls -1
...
rate-build-description-to-json_2@​libs
rate-build-description-to-json_3@​libs
rate-build-description-to-json_4@​libs
rate-build-description-to-json_5@​libs
rate-build-description-to-json_6@​libs
rate-build-description-to-json_7@​libs
rate-build-description-to-json_8@​libs
rate-build-description-to-json_9@​libs
...
$

So for me there are two questions and two possible solutions:

1. Why is the folder name stripped?

2. Why is the folder structure "flat" at this point and not like on the build jobs themself?

I think there should be at least one folder level in between like this pseudo code example:

/var/jenkins_home/workspace/OrgaScannerA/JobA-A/rate-build-description-to-json_3@​libs

/var/jenkins_home/workspace/OrgaScannerA/JobA-B/rate-build-description-to-json_3@​libs
/var/jenkins_home/workspace/OrgaScannerB/JobB-A/rate-build-description-to-json_3@​libs
/var/jenkins_home/workspace/OrgaScannerB/JobB-B/rate-build-description-to-json_3@​libs

Or the folder name itself should be unique:

/var/jenkins_home/workspace/OrgaScannerA-JobA-A-rate-build-description-to-json_3@​libs

/var/jenkins_home/workspace/OrgaScannerA-JobA-B-rate-build-description-to-json_3@​libs
/var/jenkins_home/workspace/OrgaScannerB-JobB-A-rate-build-description-to-json_3@​libs
/var/jenkins_home/workspace/OrgaScannerB-JobB-B-rate-build-description-to-json_3@​libs

---
Originally reported by swf, imported from: @libs pseudo-workspace collision due to branch name truncation


  • assignee: smasher
  • status: In Progress
  • priority: Minor
  • component(s): branch-api-plugin, pipeline-groovy-lib-plugin
  • resolution: Unresolved
  • votes: 1
  • watchers: 6
  • imported: 20251211-141027

Raw content of original issue

I've spot an issue with unwanted interaction between different, independent jobs.

Here are the details: Our Jenkins instance (2.176.1 LTS) has some global pipeline libraries configured. My task was some kind of structural migration on a bunch of different projects. So I created a corresponding branch on each of these projects, did the change there and pushed it. So all the build jobs started at the same time and surprisingly most of them failed with a strange error during initial jobs steps like this:



...

remote: Compressing objects: 100% (6/6), done.
remote: Total 8 (delta 0), reused 0 (delta 0)
error: cannot lock ref 'refs/remotes/origin/bugfix/ESTA-3146-yla': Unable to create '/var/jenkins_home/workspace/rate-build-description-to-json_5@libs/pipeline-helper/.git/refs/remotes/origin/bugfix/ESTA-3146-yla.lock': File exists.

Another git process seems to be running in this repository, e.g.
...



After digging around I figured out, that the pipeline helper libs are cloned on the Jenkins master using a folder named like the job a/o branch, which is suffixed with `_<buildnumber>@libs`. Additionally the folder name is stripped to 37 characters by removing characters from the beginning of the name. This leads to the real cause: Because of the identical branch name on each Git repository, the unique part of the folder names got lost and so the jobs try to use the same folder during their initialization steps respectively the cloning of the pipeline helper libs. As soon as the simultaneous running jobs have a differnt build number, it works as expected.

The branch was named "feature/KIHUB-7882-separate-build-description-to-json" on all modified projects respectively Git repositories and so at the master it looks like this right now:



$ cd /var/jenkins_home/workspace

$ ls -1
...
rate-build-description-to-json_2@libs
rate-build-description-to-json_3@libs
rate-build-description-to-json_4@libs
rate-build-description-to-json_5@libs
rate-build-description-to-json_6@libs
rate-build-description-to-json_7@libs
rate-build-description-to-json_8@libs
rate-build-description-to-json_9@libs
...
$


So for me there are two questions and two possible solutions:
1. Why is the folder name stripped?
2. Why is the folder structure "flat" at this point and not like on the build jobs themself?

I think there should be at least one folder level in between like this pseudo code example:



/var/jenkins_home/workspace/OrgaScannerA/JobA-A/rate-build-description-to-json_3@libs

/var/jenkins_home/workspace/OrgaScannerA/JobA-B/rate-build-description-to-json_3@libs
/var/jenkins_home/workspace/OrgaScannerB/JobB-A/rate-build-description-to-json_3@libs
/var/jenkins_home/workspace/OrgaScannerB/JobB-B/rate-build-description-to-json_3@libs


Or the folder name itself should be unique:



/var/jenkins_home/workspace/OrgaScannerA-JobA-A-rate-build-description-to-json_3@libs

/var/jenkins_home/workspace/OrgaScannerA-JobA-B-rate-build-description-to-json_3@libs
/var/jenkins_home/workspace/OrgaScannerB-JobB-A-rate-build-description-to-json_3@libs
/var/jenkins_home/workspace/OrgaScannerB-JobB-B-rate-build-description-to-json_3@libs

2 attachments

- [screenshot-1.png](https://issues.jenkins.io/secure/attachment/51067/screenshot-1.png)
> ![screenshot-1.png](https://issues.jenkins.io/secure/attachment/51067/screenshot-1.png)
- [screenshot-2.png](https://issues.jenkins.io/secure/attachment/51068/screenshot-2.png)
> ![screenshot-2.png](https://issues.jenkins.io/secure/attachment/51068/screenshot-2.png)

Contributor guide

Open the contributing guide

Research direction

The issue identifies branch-api-plugin and pipeline-groovy-lib-plugin as the relevant components; start by tracing how the @libs workspace path is derived and truncated. Done means independent simultaneous jobs with identical branch names no longer resolve to the same library workspace.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, java
Domain
devops, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.