From 8e38300d7cb3543435907834a94d335151de4cef Mon Sep 17 00:00:00 2001 From: Andrew Shirley Date: Sun, 11 Jul 2021 14:14:58 +0100 Subject: [PATCH] Consistently use job-full-name not name or slug Signed-off-by: Andrew Shirley Signed-off-by: blam --- .../well-known-annotations.md | 6 ++--- plugins/jenkins-backend/README.md | 16 +++++++----- plugins/jenkins-backend/api-report.md | 8 +++--- .../src/service/jenkinsApi.test.ts | 21 ++++++++------- .../jenkins-backend/src/service/jenkinsApi.ts | 18 ++++++------- .../src/service/jenkinsInfoProvider.test.ts | 26 +++++++++---------- .../src/service/jenkinsInfoProvider.ts | 18 ++++++------- plugins/jenkins-backend/src/service/router.ts | 22 ++++++++++------ .../src/service/standaloneServer.ts | 2 +- plugins/jenkins/src/api/JenkinsApi.ts | 22 ++++++++-------- .../BuildWithStepsPage/BuildWithStepsPage.tsx | 4 +-- .../BuildsPage/lib/CITable/CITable.tsx | 2 +- .../src/components/useBuildWithSteps.ts | 10 +++---- plugins/jenkins/src/components/useBuilds.ts | 4 +-- plugins/jenkins/src/plugin.ts | 4 +-- 15 files changed, 97 insertions(+), 86 deletions(-) diff --git a/docs/features/software-catalog/well-known-annotations.md b/docs/features/software-catalog/well-known-annotations.md index 79c55eaa50..5f474624f9 100644 --- a/docs/features/software-catalog/well-known-annotations.md +++ b/docs/features/software-catalog/well-known-annotations.md @@ -101,13 +101,13 @@ repository itself. If the URL points to a folder, it is important that it is suffixed with a `'/'` in order for relative path resolution to work consistently. -### jenkins.io/job-slug +### jenkins.io/job-full-name ```yaml # Example: metadata: annotations: - jenkins.io/job-slug: folder-name/job-name + jenkins.io/job-full-name: folder-name/job-name ``` The value of this annotation is the path to a job on Jenkins, that builds this @@ -310,7 +310,7 @@ instead. ### jenkins.io/github-folder -Use the `jenkins.io/job-slug` instead. +Use the `jenkins.io/job-full-name` instead. ## Links diff --git a/plugins/jenkins-backend/README.md b/plugins/jenkins-backend/README.md index 37d188b4eb..bac56b6eaf 100644 --- a/plugins/jenkins-backend/README.md +++ b/plugins/jenkins-backend/README.md @@ -71,10 +71,10 @@ kind: Component metadata: name: artist-lookup annotations: - 'jenkins.io/job-slug': teamA/artistLookup-build + 'jenkins.io/job-full-name': teamA/artistLookup-build ``` -The old annotation name of `jenkins.io/github-folder` is equivalent to `jenkins.io/job-slug` +The old annotation name of `jenkins.io/github-folder` is equivalent to `jenkins.io/job-full-name` #### Example - Multiple global instances @@ -103,7 +103,7 @@ kind: Component metadata: name: artist-lookup annotations: - 'jenkins.io/job-slug': departmentFoo:teamA/artistLookup-build + 'jenkins.io/job-full-name': departmentFoo:teamA/artistLookup-build ``` If the `departmentFoo:` part is omitted, the default instance will be assumed. @@ -124,7 +124,7 @@ jenkins: ### Custom JenkinsInfoProvider -An example of a bespoke JenkinsInfoProvider which uses an organisation specific annotation to look up the Jenkins info (including jobName): +An example of a bespoke JenkinsInfoProvider which uses an organisation specific annotation to look up the Jenkins info (including jobFullName): ```typescript class AcmeJenkinsInfoProvider implements JenkinsInfoProvider { @@ -132,7 +132,7 @@ class AcmeJenkinsInfoProvider implements JenkinsInfoProvider { async getInstance(opt: { entityRef: EntityName; - jobName?: string; + jobFullName?: string; }): Promise { const PAAS_ANNOTATION = 'acme.example.com/paas-project-name'; @@ -157,7 +157,7 @@ class AcmeJenkinsInfoProvider implements JenkinsInfoProvider { const { team, dept } = this.lookupPaasInfo(paasProjectName); const baseUrl = `https://jenkins-${dept}.example.com/`; - const jobName = `${team}/${paasProjectName}`; + const jobFullName = `${team}/${paasProjectName}`; const username = 'backstage-bot'; const apiKey = this.getJenkinsApiKey(paasProjectName); const creds = btoa(`${username}:${apiKey}`); @@ -167,7 +167,7 @@ class AcmeJenkinsInfoProvider implements JenkinsInfoProvider { headers: { Authorization: `Basic ${creds}`, }, - jobName, + jobFullName, }; } @@ -205,3 +205,5 @@ The domain model for Jenkins is not particularly clear but for the purposes of t Jenkins contains a tree of *job*s which have children of either; other *job*s (making it a _folder_) or *build*s (making it a _project_). Concepts like _pipeline_ and *view*s are meaningless (pipelines are just jobs for our purposes, views are (as the name suggests) just views of subsets of jobs) + +A _job full name_ is a slash separated list of the names of the job, and the folders which contain it. For example `teamA/artistLookupService/develop`, and the same way that a filesystem path has folders and file names. diff --git a/plugins/jenkins-backend/api-report.md b/plugins/jenkins-backend/api-report.md index f81c141f73..7d4ffe27c0 100644 --- a/plugins/jenkins-backend/api-report.md +++ b/plugins/jenkins-backend/api-report.md @@ -23,10 +23,10 @@ export class DefaultJenkinsInfoProvider implements JenkinsInfoProvider { // (undocumented) getInstance(opt: { entityRef: EntityName; - jobName?: string; + jobFullName?: string; }): Promise; // (undocumented) - static readonly NEW_JENKINS_ANNOTATION = "jenkins.io/job-slug"; + static readonly NEW_JENKINS_ANNOTATION = "jenkins.io/job-full-name"; // (undocumented) static readonly OLD_JENKINS_ANNOTATION = "jenkins.io/github-folder"; } @@ -38,7 +38,7 @@ export interface JenkinsInfo { // (undocumented) headers?: Record; // (undocumented) - jobName: string; + jobFullName: string; } // @public (undocumented) @@ -46,7 +46,7 @@ export interface JenkinsInfoProvider { // (undocumented) getInstance(options: { entityRef: EntityName; - jobName?: string; + jobFullName?: string; }): Promise; } diff --git a/plugins/jenkins-backend/src/service/jenkinsApi.test.ts b/plugins/jenkins-backend/src/service/jenkinsApi.test.ts index fc2ccb3748..380a65f895 100644 --- a/plugins/jenkins-backend/src/service/jenkinsApi.test.ts +++ b/plugins/jenkins-backend/src/service/jenkinsApi.test.ts @@ -31,12 +31,12 @@ const mockedJenkinsClient = { const mockedJenkins = jenkins as jest.Mocked; mockedJenkins.mockReturnValue(mockedJenkinsClient); -const jobName = 'example-jobName/foo'; +const jobFullName = 'example-jobName/foo'; const buildNumber = 19; const jenkinsInfo: JenkinsInfo = { baseUrl: 'https://jenkins.example.com', headers: { headerName: 'headerValue' }, - jobName: 'example-jobName', + jobFullName: 'example-jobName', }; describe('JenkinsApi', () => { @@ -74,7 +74,7 @@ describe('JenkinsApi', () => { promisify: true, }); expect(mockedJenkinsClient.job.get).toBeCalledWith({ - name: jenkinsInfo.jobName, + name: jenkinsInfo.jobFullName, tree: expect.anything(), }); expect(result).toHaveLength(1); @@ -117,7 +117,7 @@ describe('JenkinsApi', () => { promisify: true, }); expect(mockedJenkinsClient.job.get).toBeCalledWith({ - name: `${jenkinsInfo.jobName}/testBranchName`, + name: `${jenkinsInfo.jobFullName}/testBranchName`, tree: expect.anything(), }); expect(result).toHaveLength(1); @@ -368,7 +368,7 @@ describe('JenkinsApi', () => { mockedJenkinsClient.job.get.mockResolvedValueOnce(project); mockedJenkinsClient.build.get.mockResolvedValueOnce(build); - await jenkinsApi.getBuild(jenkinsInfo, jobName, buildNumber); + await jenkinsApi.getBuild(jenkinsInfo, jobFullName, buildNumber); expect(mockedJenkins).toHaveBeenCalledWith({ baseUrl: jenkinsInfo.baseUrl, @@ -376,19 +376,22 @@ describe('JenkinsApi', () => { promisify: true, }); expect(mockedJenkinsClient.job.get).toBeCalledWith({ - name: jobName, + name: jobFullName, depth: 1, }); - expect(mockedJenkinsClient.build.get).toBeCalledWith(jobName, buildNumber); + expect(mockedJenkinsClient.build.get).toBeCalledWith( + jobFullName, + buildNumber, + ); }); it('buildProject', async () => { - await jenkinsApi.buildProject(jenkinsInfo, jobName); + await jenkinsApi.buildProject(jenkinsInfo, jobFullName); expect(mockedJenkins).toHaveBeenCalledWith({ baseUrl: jenkinsInfo.baseUrl, headers: jenkinsInfo.headers, promisify: true, }); - expect(mockedJenkinsClient.job.build).toBeCalledWith(jobName); + expect(mockedJenkinsClient.job.build).toBeCalledWith(jobFullName); }); }); diff --git a/plugins/jenkins-backend/src/service/jenkinsApi.ts b/plugins/jenkins-backend/src/service/jenkinsApi.ts index f7476daab9..7df5c5db1d 100644 --- a/plugins/jenkins-backend/src/service/jenkinsApi.ts +++ b/plugins/jenkins-backend/src/service/jenkinsApi.ts @@ -67,18 +67,18 @@ export class JenkinsApiImpl { if (branch) { // we have been asked to filter to a single branch. - // Assume jenkinsInfo.jobName is a folder which contains one job per branch. + // Assume jenkinsInfo.jobFullName is a folder which contains one job per branch. // TODO: extract a strategy interface for this const job = await client.job.get({ - name: `${jenkinsInfo.jobName}/${branch}`, + name: `${jenkinsInfo.jobFullName}/${branch}`, tree: JenkinsApiImpl.jobTreeSpec.replace(/\s/g, ''), }); projects.push(this.augmentProject(job)); } else { // We aren't filtering - // Assume jenkinsInfo.jobName is a folder which contains one job per branch. + // Assume jenkinsInfo.jobFullName is a folder which contains one job per branch. const folder = await client.job.get({ - name: jenkinsInfo.jobName, + name: jenkinsInfo.jobFullName, // Filter only be the information we need, instead of loading all fields. // Limit to only show the latest build for each job and only load 50 jobs // at all. @@ -107,17 +107,17 @@ export class JenkinsApiImpl { */ async getBuild( jenkinsInfo: JenkinsInfo, - jobName: string, + jobFullName: string, buildNumber: number, ) { const client = await JenkinsApiImpl.getClient(jenkinsInfo); const project = await client.job.get({ - name: jobName, + name: jobFullName, depth: 1, }); - const build = await client.build.get(jobName, buildNumber); + const build = await client.build.get(jobFullName, buildNumber); const jobScmInfo = JenkinsApiImpl.extractScmDetailsFromJob(project); return this.augmentBuild(build, jobScmInfo); @@ -127,7 +127,7 @@ export class JenkinsApiImpl { * Trigger a build of a project * @see ../../../jenkins/src/api/JenkinsApi.ts#retry */ - async buildProject(jenkinsInfo: JenkinsInfo, jobName: string) { + async buildProject(jenkinsInfo: JenkinsInfo, jobFullName: string) { const client = await JenkinsApiImpl.getClient(jenkinsInfo); // looks like the current SDK only supports triggering a new build @@ -135,7 +135,7 @@ export class JenkinsApiImpl { // Note Jenkins itself has concepts of rebuild and replay on a job. // The latter should be possible to trigger with a POST to /replay/rebuild - await client.job.build(jobName); + await client.job.build(jobFullName); } // private helper methods diff --git a/plugins/jenkins-backend/src/service/jenkinsInfoProvider.test.ts b/plugins/jenkins-backend/src/service/jenkinsInfoProvider.test.ts index 4651d7a489..7c4761a19a 100644 --- a/plugins/jenkins-backend/src/service/jenkinsInfoProvider.test.ts +++ b/plugins/jenkins-backend/src/service/jenkinsInfoProvider.test.ts @@ -61,7 +61,7 @@ describe('DefaultJenkinsInfoProvider', () => { { metadata: { annotations: { - 'jenkins.io/job-slug': 'teamA/artistLookup-build', + 'jenkins.io/job-full-name': 'teamA/artistLookup-build', }, }, }, @@ -75,7 +75,7 @@ describe('DefaultJenkinsInfoProvider', () => { Authorization: 'Basic YmFja3N0YWdlIC0gYm90OjEyMzQ1Njc4OWFiY2RlZjAxMjM0NTY3ODlhYmNlZGYwMTI=', }, - jobName: 'teamA/artistLookup-build', + jobFullName: 'teamA/artistLookup-build', }); }); @@ -96,7 +96,7 @@ describe('DefaultJenkinsInfoProvider', () => { { metadata: { annotations: { - 'jenkins.io/job-slug': 'teamA/artistLookup-build', + 'jenkins.io/job-full-name': 'teamA/artistLookup-build', }, }, }, @@ -106,7 +106,7 @@ describe('DefaultJenkinsInfoProvider', () => { expect(mockCatalog.getEntityByName).toBeCalledWith(entityRef); expect(info).toMatchObject({ baseUrl: 'https://jenkins.example.com', - jobName: 'teamA/artistLookup-build', + jobFullName: 'teamA/artistLookup-build', }); }); @@ -133,7 +133,7 @@ describe('DefaultJenkinsInfoProvider', () => { { metadata: { annotations: { - 'jenkins.io/job-slug': 'teamA/artistLookup-build', + 'jenkins.io/job-full-name': 'teamA/artistLookup-build', }, }, }, @@ -143,7 +143,7 @@ describe('DefaultJenkinsInfoProvider', () => { expect(mockCatalog.getEntityByName).toBeCalledWith(entityRef); expect(info).toMatchObject({ baseUrl: 'https://jenkins.example.com', - jobName: 'teamA/artistLookup-build', + jobFullName: 'teamA/artistLookup-build', }); }); @@ -170,7 +170,7 @@ describe('DefaultJenkinsInfoProvider', () => { { metadata: { annotations: { - 'jenkins.io/job-slug': 'other:teamA/artistLookup-build', + 'jenkins.io/job-full-name': 'other:teamA/artistLookup-build', }, }, }, @@ -180,7 +180,7 @@ describe('DefaultJenkinsInfoProvider', () => { expect(mockCatalog.getEntityByName).toBeCalledWith(entityRef); expect(info).toMatchObject({ baseUrl: 'https://jenkins-other.example.com', - jobName: 'teamA/artistLookup-build', + jobFullName: 'teamA/artistLookup-build', }); }); @@ -196,7 +196,7 @@ describe('DefaultJenkinsInfoProvider', () => { { metadata: { annotations: { - 'jenkins.io/job-slug': 'default:teamA/artistLookup-build', + 'jenkins.io/job-full-name': 'default:teamA/artistLookup-build', }, }, }, @@ -206,7 +206,7 @@ describe('DefaultJenkinsInfoProvider', () => { expect(mockCatalog.getEntityByName).toBeCalledWith(entityRef); expect(info).toMatchObject({ baseUrl: 'https://jenkins.example.com', - jobName: 'teamA/artistLookup-build', + jobFullName: 'teamA/artistLookup-build', }); }); @@ -232,7 +232,7 @@ describe('DefaultJenkinsInfoProvider', () => { expect(mockCatalog.getEntityByName).toBeCalledWith(entityRef); expect(info).toMatchObject({ baseUrl: 'https://jenkins.example.com', - jobName: 'teamA/artistLookup-build', + jobFullName: 'teamA/artistLookup-build', }); }); @@ -253,7 +253,7 @@ describe('DefaultJenkinsInfoProvider', () => { { metadata: { annotations: { - 'jenkins.io/job-slug': 'other:teamA/artistLookup-build', + 'jenkins.io/job-full-name': 'other:teamA/artistLookup-build', }, }, }, @@ -263,7 +263,7 @@ describe('DefaultJenkinsInfoProvider', () => { expect(mockCatalog.getEntityByName).toBeCalledWith(entityRef); expect(info).toMatchObject({ baseUrl: 'https://jenkins-other.example.com', - jobName: 'teamA/artistLookup-build', + jobFullName: 'teamA/artistLookup-build', }); }); }); diff --git a/plugins/jenkins-backend/src/service/jenkinsInfoProvider.ts b/plugins/jenkins-backend/src/service/jenkinsInfoProvider.ts index 2314aa80af..1f316aa6bc 100644 --- a/plugins/jenkins-backend/src/service/jenkinsInfoProvider.ts +++ b/plugins/jenkins-backend/src/service/jenkinsInfoProvider.ts @@ -30,14 +30,14 @@ export interface JenkinsInfoProvider { /** * A specific job to get. This is only passed in when we know about a job name we are interested in. */ - jobName?: string; + jobFullName?: string; }): Promise; } export interface JenkinsInfo { baseUrl: string; headers?: Record; - jobName: string; // TODO: make this an array + jobFullName: string; // TODO: make this an array } /** @@ -47,7 +47,7 @@ export interface JenkinsInfo { */ export class DefaultJenkinsInfoProvider implements JenkinsInfoProvider { static readonly OLD_JENKINS_ANNOTATION = 'jenkins.io/github-folder'; - static readonly NEW_JENKINS_ANNOTATION = 'jenkins.io/job-slug'; + static readonly NEW_JENKINS_ANNOTATION = 'jenkins.io/job-full-name'; private constructor( private readonly config: { @@ -71,7 +71,7 @@ export class DefaultJenkinsInfoProvider implements JenkinsInfoProvider { async getInstance(opt: { entityRef: EntityName; - jobName?: string; + jobFullName?: string; }): Promise { // load entity const entity = await this.catalog.getEntityByName(opt.entityRef); @@ -81,7 +81,7 @@ export class DefaultJenkinsInfoProvider implements JenkinsInfoProvider { ); } - // lookup `[jenkinsName#]jobName` from entity annotation + // lookup `[jenkinsName#]jobFullName` from entity annotation const jenkinsAndJobName = DefaultJenkinsInfoProvider.getEntityAnnotationValue( entity, ); @@ -93,16 +93,16 @@ export class DefaultJenkinsInfoProvider implements JenkinsInfoProvider { ); } - let jobName; + let jobFullName; let jenkinsName: string | undefined; const splitIndex = jenkinsAndJobName.indexOf(':'); if (splitIndex === -1) { // no jenkinsName specified, use default - jobName = jenkinsAndJobName; + jobFullName = jenkinsAndJobName; } else { // There is a jenkinsName specified jenkinsName = jenkinsAndJobName.substring(0, splitIndex); - jobName = jenkinsAndJobName.substring( + jobFullName = jenkinsAndJobName.substring( splitIndex + 1, jenkinsAndJobName.length, ); @@ -124,7 +124,7 @@ export class DefaultJenkinsInfoProvider implements JenkinsInfoProvider { headers: { Authorization: `Basic ${creds}`, }, - jobName, + jobFullName, }; } diff --git a/plugins/jenkins-backend/src/service/router.ts b/plugins/jenkins-backend/src/service/router.ts index 360dfb004d..cd250aea31 100644 --- a/plugins/jenkins-backend/src/service/router.ts +++ b/plugins/jenkins-backend/src/service/router.ts @@ -73,9 +73,15 @@ export async function createRouter( ); router.get( - '/v1/entity/:namespace/:kind/:name/job/:jobName/:buildNumber', + '/v1/entity/:namespace/:kind/:name/job/:jobFullName/:buildNumber', async (request, response) => { - const { namespace, kind, name, jobName, buildNumber } = request.params; + const { + namespace, + kind, + name, + jobFullName, + buildNumber, + } = request.params; const jenkinsInfo = await jenkinsInfoProvider.getInstance({ entityRef: { @@ -83,12 +89,12 @@ export async function createRouter( namespace, name, }, - jobName, + jobFullName, }); const build = await jenkinsApi.getBuild( jenkinsInfo, - jobName, + jobFullName, parseInt(buildNumber, 10), ); @@ -99,9 +105,9 @@ export async function createRouter( ); router.post( - '/v1/entity/:namespace/:kind/:name/job/:jobName/:buildNumber::rebuild', + '/v1/entity/:namespace/:kind/:name/job/:jobFullName/:buildNumber::rebuild', async (request, response) => { - const { namespace, kind, name, jobName } = request.params; + const { namespace, kind, name, jobFullName } = request.params; const jenkinsInfo = await jenkinsInfoProvider.getInstance({ entityRef: { @@ -109,10 +115,10 @@ export async function createRouter( namespace, name, }, - jobName, + jobFullName, }); - await jenkinsApi.buildProject(jenkinsInfo, jobName); + await jenkinsApi.buildProject(jenkinsInfo, jobFullName); response.json({}); }, ); diff --git a/plugins/jenkins-backend/src/service/standaloneServer.ts b/plugins/jenkins-backend/src/service/standaloneServer.ts index 3b201946bb..a1bc5dd256 100644 --- a/plugins/jenkins-backend/src/service/standaloneServer.ts +++ b/plugins/jenkins-backend/src/service/standaloneServer.ts @@ -36,7 +36,7 @@ export async function startStandaloneServer( logger, jenkinsInfoProvider: { async getInstance(_: { entityRef: EntityRef }): Promise { - return { baseUrl: 'https://example.com/', jobName: 'build-foo' }; + return { baseUrl: 'https://example.com/', jobFullName: 'build-foo' }; }, }, }); diff --git a/plugins/jenkins/src/api/JenkinsApi.ts b/plugins/jenkins/src/api/JenkinsApi.ts index d37fdd2032..4b23fb4292 100644 --- a/plugins/jenkins/src/api/JenkinsApi.ts +++ b/plugins/jenkins/src/api/JenkinsApi.ts @@ -91,20 +91,20 @@ export interface JenkinsApi { * * This takes an entity to support selecting between multiple jenkins instances. * - * TODO: abstract jobName (so we could support differentiating between the same named job on multiple instances). + * TODO: abstract jobFullName (so we could support differentiating between the same named job on multiple instances). * @param options.entity - * @param options.jobName + * @param options.jobFullName * @param options.buildNumber */ getBuild(options: { entity: EntityName; - jobName: string; + jobFullName: string; buildNumber: string; }): Promise; retry(options: { entity: EntityName; - jobName: string; + jobFullName: string; buildNumber: string; }): Promise; } @@ -154,7 +154,7 @@ export class JenkinsClient implements JenkinsApi { onRestartClick: async () => { await this.retry({ entity, - jobName: p.fullName, + jobFullName: p.fullName, buildNumber: String(p.lastBuild.number), }); }, @@ -164,11 +164,11 @@ export class JenkinsClient implements JenkinsApi { async getBuild({ entity, - jobName, + jobFullName, buildNumber, }: { entity: EntityName; - jobName: string; + jobFullName: string; buildNumber: string; }): Promise { const url = `${await this.discoveryApi.getBaseUrl( @@ -176,7 +176,7 @@ export class JenkinsClient implements JenkinsApi { )}/v1/entity/${encodeURIComponent(entity.namespace)}/${encodeURIComponent( entity.kind, )}/${encodeURIComponent(entity.name)}/job/${encodeURIComponent( - jobName, + jobFullName, )}/${encodeURIComponent(buildNumber)}`; const idToken = await this.identityApi.getIdToken(); @@ -192,11 +192,11 @@ export class JenkinsClient implements JenkinsApi { async retry({ entity, - jobName, + jobFullName, buildNumber, }: { entity: EntityName; - jobName: string; + jobFullName: string; buildNumber: string; }): Promise { const url = `${await this.discoveryApi.getBaseUrl( @@ -204,7 +204,7 @@ export class JenkinsClient implements JenkinsApi { )}/v1/entity/${encodeURIComponent(entity.namespace)}/${encodeURIComponent( entity.kind, )}/${encodeURIComponent(entity.name)}/job/${encodeURIComponent( - jobName, + jobFullName, )}/${encodeURIComponent(buildNumber)}:rebuild`; const idToken = await this.identityApi.getIdToken(); diff --git a/plugins/jenkins/src/components/BuildWithStepsPage/BuildWithStepsPage.tsx b/plugins/jenkins/src/components/BuildWithStepsPage/BuildWithStepsPage.tsx index 255fc949b2..e06332f8f0 100644 --- a/plugins/jenkins/src/components/BuildWithStepsPage/BuildWithStepsPage.tsx +++ b/plugins/jenkins/src/components/BuildWithStepsPage/BuildWithStepsPage.tsx @@ -49,10 +49,10 @@ const useStyles = makeStyles(theme => ({ const BuildWithStepsView = () => { // TODO: Add a test that react-router decodes this (even though `generatePath` doesn't encode it for you!) - const { jobName, buildNumber } = useRouteRefParams(buildRouteRef); + const { jobFullName, buildNumber } = useRouteRefParams(buildRouteRef); const classes = useStyles(); - const [{ value }] = useBuildWithSteps({ jobName, buildNumber }); + const [{ value }] = useBuildWithSteps({ jobFullName, buildNumber }); return (
diff --git a/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx b/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx index 7c1e7db8b1..3e5eeffdaa 100644 --- a/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx +++ b/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx @@ -100,7 +100,7 @@ const generatedColumns: TableColumn[] = [ diff --git a/plugins/jenkins/src/components/useBuildWithSteps.ts b/plugins/jenkins/src/components/useBuildWithSteps.ts index e82a4800d5..c73a116aae 100644 --- a/plugins/jenkins/src/components/useBuildWithSteps.ts +++ b/plugins/jenkins/src/components/useBuildWithSteps.ts @@ -25,14 +25,14 @@ const INTERVAL_AMOUNT = 1500; /** * Hook to expose a specific build. - * @param jobName the full name of the project (job with builds, not a folder). e.g. "department-A/team-1/project-foo/master" + * @param jobFullName the full name of the project (job with builds, not a folder). e.g. "department-A/team-1/project-foo/master" * @param buildNumber the number of the build. e.g. "13" */ export function useBuildWithSteps({ - jobName, + jobFullName, buildNumber, }: { - jobName: string; + jobFullName: string; buildNumber: string; }) { const api = useApi(jenkinsApiRef); @@ -42,12 +42,12 @@ export function useBuildWithSteps({ const getBuildWithSteps = useCallback(async () => { try { const entityName = await getEntityName(entity); - return api.getBuild({ entity: entityName, jobName, buildNumber }); + return api.getBuild({ entity: entityName, jobFullName, buildNumber }); } catch (e) { errorApi.post(e); return Promise.reject(e); } - }, [buildNumber, jobName, entity, api, errorApi]); + }, [buildNumber, jobFullName, entity, api, errorApi]); const { loading, value, retry } = useAsyncRetry(() => getBuildWithSteps(), [ getBuildWithSteps, diff --git a/plugins/jenkins/src/components/useBuilds.ts b/plugins/jenkins/src/components/useBuilds.ts index ad068dd219..820cb099a1 100644 --- a/plugins/jenkins/src/components/useBuilds.ts +++ b/plugins/jenkins/src/components/useBuilds.ts @@ -45,9 +45,9 @@ export function useBuilds({ branch }: { branch?: string } = {}) { errorType: ErrorType; }>(); - const restartBuild = async (jobName: string, buildNumber: string) => { + const restartBuild = async (jobFullName: string, buildNumber: string) => { try { - await api.retry({ entity: entityName, jobName, buildNumber }); + await api.retry({ entity: entityName, jobFullName, buildNumber }); } catch (e) { errorApi.post(e); } diff --git a/plugins/jenkins/src/plugin.ts b/plugins/jenkins/src/plugin.ts index fd6291618a..e975361da2 100644 --- a/plugins/jenkins/src/plugin.ts +++ b/plugins/jenkins/src/plugin.ts @@ -31,8 +31,8 @@ export const rootRouteRef = createRouteRef({ }); export const buildRouteRef = createRouteRef({ - path: 'build/:jobName/:buildNumber', - params: ['jobName', 'buildNumber'], + path: 'build/:jobFullName/:buildNumber', + params: ['jobFullName', 'buildNumber'], title: 'Jenkins build', });