diff --git a/plugins/jenkins/src/components/BuildWithStepsPage/BuildWithStepsPage.tsx b/plugins/jenkins/src/components/BuildWithStepsPage/BuildWithStepsPage.tsx
index 9d8a4c11e4..255fc949b2 100644
--- a/plugins/jenkins/src/components/BuildWithStepsPage/BuildWithStepsPage.tsx
+++ b/plugins/jenkins/src/components/BuildWithStepsPage/BuildWithStepsPage.tsx
@@ -52,7 +52,7 @@ const BuildWithStepsView = () => {
const { jobName, buildNumber } = useRouteRefParams(buildRouteRef);
const classes = useStyles();
- const [{ value }] = useBuildWithSteps(jobName, buildNumber);
+ const [{ value }] = useBuildWithSteps({ jobName, buildNumber });
return (
diff --git a/plugins/jenkins/src/components/Cards/Cards.tsx b/plugins/jenkins/src/components/Cards/Cards.tsx
index 7f05a1ba3e..f0b1ff2bca 100644
--- a/plugins/jenkins/src/components/Cards/Cards.tsx
+++ b/plugins/jenkins/src/components/Cards/Cards.tsx
@@ -100,7 +100,7 @@ export const LatestRunCard = ({
branch: string;
variant?: InfoCardVariants;
}) => {
- const [{ projects, loading, error }] = useBuilds(branch);
+ const [{ projects, loading, error }] = useBuilds({ branch });
const latestRun = projects?.[0];
return (
diff --git a/plugins/jenkins/src/components/useBuildWithSteps.ts b/plugins/jenkins/src/components/useBuildWithSteps.ts
index 82f3634941..b109c9f964 100644
--- a/plugins/jenkins/src/components/useBuildWithSteps.ts
+++ b/plugins/jenkins/src/components/useBuildWithSteps.ts
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import { useCallback, useMemo } from 'react';
+import { useCallback } from 'react';
import { useAsyncRetry } from 'react-use';
import { jenkinsApiRef } from '../api';
import { useAsyncPolling } from './useAsyncPolling';
@@ -28,20 +28,26 @@ const INTERVAL_AMOUNT = 1500;
* @param jobName 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: string, buildNumber: string) {
+export function useBuildWithSteps({
+ jobName,
+ buildNumber,
+}: {
+ jobName: string;
+ buildNumber: string;
+}) {
const api = useApi(jenkinsApiRef);
const errorApi = useApi(errorApiRef);
const { entity } = useEntity();
- const entityName = useMemo(() => getEntityName(entity), [entity]);
const getBuildWithSteps = useCallback(async () => {
try {
+ const entityName = await getEntityName(entity);
return api.getBuild(entityName, jobName, buildNumber);
} catch (e) {
errorApi.post(e);
return Promise.reject(e);
}
- }, [buildNumber, jobName, entityName, api, errorApi]);
+ }, [buildNumber, jobName, 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 f3c8878047..8a68e6f1cf 100644
--- a/plugins/jenkins/src/components/useBuilds.ts
+++ b/plugins/jenkins/src/components/useBuilds.ts
@@ -31,7 +31,7 @@ export enum ErrorType {
*
* TODO: deprecate branch and add a generic filter concept.
*/
-export function useBuilds(branch?: string) {
+export function useBuilds({ branch }: { branch?: string } = {}) {
const { entity } = useEntity();
const entityName = getEntityName(entity);
const api = useApi(jenkinsApiRef);