improve support for branches with slashes

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2023-05-02 13:11:37 +02:00
parent d1797f0e91
commit 670a2dd6f4
3 changed files with 11 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-jenkins-backend': patch
---
Fix handling of slashes in branch names
@@ -173,6 +173,7 @@ describe('JenkinsApi', () => {
'foo',
'bar',
'catpants',
'with-a/slash',
]);
expect(mockedJenkins).toHaveBeenCalledWith({
@@ -192,6 +193,10 @@ describe('JenkinsApi', () => {
name: `${jenkinsInfo.jobFullName}/catpants`,
tree: expect.anything(),
});
expect(mockedJenkinsClient.job.get).toHaveBeenCalledWith({
name: `${jenkinsInfo.jobFullName}/with-a%2Fslash`,
tree: expect.anything(),
});
expect(result).toHaveLength(1);
});
});
@@ -80,7 +80,7 @@ export class JenkinsApiImpl {
const job = await Promise.any(
branches.map(branch =>
client.job.get({
name: `${jenkinsInfo.jobFullName}/${branch}`,
name: `${jenkinsInfo.jobFullName}/${encodeURIComponent(branch)}`,
tree: JenkinsApiImpl.jobTreeSpec.replace(/\s/g, ''),
}),
),