Consistently use job-full-name not name or slug
Signed-off-by: Andrew Shirley <andrew.shirley@sainsburys.co.uk> Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
@@ -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<Build>;
|
||||
|
||||
retry(options: {
|
||||
entity: EntityName;
|
||||
jobName: string;
|
||||
jobFullName: string;
|
||||
buildNumber: string;
|
||||
}): Promise<void>;
|
||||
}
|
||||
@@ -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<Build> {
|
||||
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<void> {
|
||||
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();
|
||||
|
||||
@@ -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 (
|
||||
<div className={classes.root}>
|
||||
|
||||
@@ -100,7 +100,7 @@ const generatedColumns: TableColumn[] = [
|
||||
<Link
|
||||
component={RouterLink}
|
||||
to={generatePath(buildRouteRef.path, {
|
||||
jobName: encodeURIComponent(row.fullName),
|
||||
jobFullName: encodeURIComponent(row.fullName),
|
||||
buildNumber: String(row.lastBuild?.number),
|
||||
})}
|
||||
>
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user