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/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..50a59db696 100644 --- a/plugins/jenkins/src/constants.ts +++ b/plugins/jenkins/src/constants.ts @@ -13,4 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export const JENKINS_ANNOTATION = 'jenkins.io/github-folder'; + +export const LEGACY_JENKINS_ANNOTATION = 'jenkins.io/github-folder'; +export const JENKINS_ANNOTATION = 'jenkins.io/job-full-name'; 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';