diff --git a/.changeset/quick-trains-flow.md b/.changeset/quick-trains-flow.md new file mode 100644 index 0000000000..447dc0aacc --- /dev/null +++ b/.changeset/quick-trains-flow.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-jenkins': patch +--- + +Make `isJenkinsAvailable` recognise both the old and the new Jenkins annotation. diff --git a/plugins/jenkins/api-report.md b/plugins/jenkins/api-report.md index 883e74071d..5a50c14f87 100644 --- a/plugins/jenkins/api-report.md +++ b/plugins/jenkins/api-report.md @@ -43,7 +43,7 @@ export { isJenkinsAvailable as isPluginApplicableToEntity }; // Warning: (ae-missing-release-tag) "JENKINS_ANNOTATION" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const JENKINS_ANNOTATION = 'jenkins.io/github-folder'; +export const JENKINS_ANNOTATION = 'jenkins.io/job-full-name'; // Warning: (ae-missing-release-tag) "JenkinsApi" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -143,6 +143,11 @@ export const LatestRunCard: ({ variant?: InfoCardVariants | undefined; }) => JSX.Element; +// Warning: (ae-missing-release-tag) "LEGACY_JENKINS_ANNOTATION" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export const LEGACY_JENKINS_ANNOTATION = 'jenkins.io/github-folder'; + // Warning: (ae-forgotten-export) The symbol "Props" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "Router" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // diff --git a/plugins/jenkins/src/components/Router.tsx b/plugins/jenkins/src/components/Router.tsx index bb5d7b9108..35b769e9d9 100644 --- a/plugins/jenkins/src/components/Router.tsx +++ b/plugins/jenkins/src/components/Router.tsx @@ -13,18 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { Entity } from '@backstage/catalog-model'; +import { MissingAnnotationEmptyState } from '@backstage/core-components'; +import { useEntity } from '@backstage/plugin-catalog-react'; import React from 'react'; import { Route, Routes } from 'react-router'; -import { useEntity } from '@backstage/plugin-catalog-react'; +import { JENKINS_ANNOTATION, LEGACY_JENKINS_ANNOTATION } from '../constants'; import { buildRouteRef, rootRouteRef } from '../plugin'; -import { DetailedViewPage } from './BuildWithStepsPage/'; -import { JENKINS_ANNOTATION } from '../constants'; -import { Entity } from '@backstage/catalog-model'; import { CITable } from './BuildsPage/lib/CITable'; -import { MissingAnnotationEmptyState } from '@backstage/core-components'; +import { DetailedViewPage } from './BuildWithStepsPage/'; export const isJenkinsAvailable = (entity: Entity) => - Boolean(entity.metadata.annotations?.[JENKINS_ANNOTATION]); + Boolean(entity.metadata.annotations?.[JENKINS_ANNOTATION]) || + Boolean(entity.metadata.annotations?.[LEGACY_JENKINS_ANNOTATION]); type Props = { /** @deprecated The entity is now grabbed from context instead */ diff --git a/plugins/jenkins/src/constants.ts b/plugins/jenkins/src/constants.ts index 28aa50057e..e1be37ee46 100644 --- a/plugins/jenkins/src/constants.ts +++ b/plugins/jenkins/src/constants.ts @@ -13,4 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export const JENKINS_ANNOTATION = 'jenkins.io/github-folder'; +export const JENKINS_ANNOTATION = 'jenkins.io/job-full-name'; +// @deprecated The legacy annotation used for identifing Jenkins jobs, use +// JENKINS_ANNOTATION instead. +export const LEGACY_JENKINS_ANNOTATION = 'jenkins.io/github-folder'; diff --git a/plugins/jenkins/src/index.ts b/plugins/jenkins/src/index.ts index fb0a27cb26..2f11e03f3f 100644 --- a/plugins/jenkins/src/index.ts +++ b/plugins/jenkins/src/index.ts @@ -26,5 +26,5 @@ export { isJenkinsAvailable, isJenkinsAvailable as isPluginApplicableToEntity, } from './components/Router'; -export { JENKINS_ANNOTATION } from './constants'; +export { JENKINS_ANNOTATION, LEGACY_JENKINS_ANNOTATION } from './constants'; export * from './api';