From 65ba90871980795478f8a394cd7fb48b371bbac4 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Thu, 10 Nov 2022 17:35:08 +0100 Subject: [PATCH] Provide an url when possible on deployment environment We want to be able to easily access to an environment when possible from the deployment page. It needs to be provided as environment_url when making deployment status call. https://docs.github.com/en/rest/deployments/statuses#create-a-deployment-status For people who use the classic Github Action to mark deployment as suggested by Jira. It's here: https://github.com/chrnorm/deployment-action/blob/880668c419e283adc6b1cc092d52eb5e558fec4d/action.yml#L31-L33 Related: - https://github.com/atlassian/github-for-jira/issues/1536 - https://github.com/atlassian/github-for-jira/pull/1732 --- src/interfaces/jira.ts | 1 + src/sync/deployment.ts | 1 + src/transforms/transform-deployment.test.ts | 3 ++- src/transforms/transform-deployment.ts | 3 ++- test/fixtures/deployment_status-basic.json | 1 + test/fixtures/deployment_status_staging.json | 1 + 6 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/interfaces/jira.ts b/src/interfaces/jira.ts index 3758b30d46..0469558752 100644 --- a/src/interfaces/jira.ts +++ b/src/interfaces/jira.ts @@ -146,6 +146,7 @@ export interface JiraDeployment { id: string; displayName: string; type: string; + url: string; }; associations: JiraAssociation[]; } diff --git a/src/sync/deployment.ts b/src/sync/deployment.ts index 6f7fabf8ff..05f6dfe04c 100644 --- a/src/sync/deployment.ts +++ b/src/sync/deployment.ts @@ -33,6 +33,7 @@ const getTransformedDeployments = async (deployments, gitHubInstallationClient: environment: deployment.environment, id: deployment.databaseId, target_url: deployment.latestStatus?.logUrl, + environment_url: deployment.latestStatus?.environmentUrl, updated_at: deployment.latestStatus?.updatedAt, state: deployment.latestStatus?.state } diff --git a/src/transforms/transform-deployment.test.ts b/src/transforms/transform-deployment.test.ts index 23c9efaa4b..d6059d4c1e 100644 --- a/src/transforms/transform-deployment.test.ts +++ b/src/transforms/transform-deployment.test.ts @@ -71,7 +71,8 @@ const buildJiraPayload = (associations) => { environment: { id: "Production", displayName: "Production", - type: "production" + type: "production", + url: "https://test-repo-url.env-production.company.io" }, associations }] diff --git a/src/transforms/transform-deployment.ts b/src/transforms/transform-deployment.ts index 749442ebba..2c2acdc834 100644 --- a/src/transforms/transform-deployment.ts +++ b/src/transforms/transform-deployment.ts @@ -303,7 +303,8 @@ export const transformDeployment = async (githubInstallationClient: GitHubInstal environment: { id: deployment_status.environment, displayName: deployment_status.environment, - type: environment + type: environment, + url: deployment_status.environment_url }, associations }] diff --git a/test/fixtures/deployment_status-basic.json b/test/fixtures/deployment_status-basic.json index 4b5d65ec5e..4f1732e424 100644 --- a/test/fixtures/deployment_status-basic.json +++ b/test/fixtures/deployment_status-basic.json @@ -12,6 +12,7 @@ "description": "", "environment": "Production", "target_url": "test-repo-url/commit/885bee1-commit-id-1c458/checks", + "environment_url": "https://test-repo-url.env-production.company.io", "created_at": "2021-06-28T12:15:18Z", "updated_at": "2021-06-28T12:15:18Z" }, diff --git a/test/fixtures/deployment_status_staging.json b/test/fixtures/deployment_status_staging.json index c1fbc5ff1d..ce03722dda 100644 --- a/test/fixtures/deployment_status_staging.json +++ b/test/fixtures/deployment_status_staging.json @@ -12,6 +12,7 @@ "description": "", "environment": "foo42", "target_url": "test-repo-url/commit/885bee1-commit-id-1c458/checks", + "environment_url": "https://test-repo-url.env-foo.company.io", "created_at": "2021-06-28T12:15:18Z", "updated_at": "2021-06-28T12:15:18Z" },