Merge pull request #17613 from backstage/freben/jenkins-slash

improve support for branches with slashes
This commit is contained in:
Fredrik Adelöw
2023-05-02 15:04:34 +02:00
committed by GitHub
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, ''),
}),
),