diff --git a/CHANGELOG.md b/CHANGELOG.md index 47197d09b..0581c1b11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ Note: Can be used with `sfdx plugins:install sfdx-hardis@beta` and docker image - Fix init sfdx-hardis project commands and docs - Display warning message in case package.xml has wrong format - Allow to override package-no-overwrite from a branch .sfdx-hardis.yml config file + - Using target_branch for Jira labels when isDeployBeforeMerge flag is true - Doc - Update Microsoft Teams notifications integration User Guide diff --git a/src/common/ticketProvider/ticketProviderRoot.ts b/src/common/ticketProvider/ticketProviderRoot.ts index fa1a1e033..eee426b37 100644 --- a/src/common/ticketProvider/ticketProviderRoot.ts +++ b/src/common/ticketProvider/ticketProviderRoot.ts @@ -2,6 +2,7 @@ import { SfError } from "@salesforce/core"; import c from "chalk"; import { Ticket } from "./index.js"; import { getCurrentGitBranch, uxLog } from "../utils/index.js"; +import { GitProvider } from "../gitProvider/index.js"; export abstract class TicketProviderRoot { public isActive = false; @@ -25,9 +26,20 @@ export abstract class TicketProviderRoot { public async getDeploymentTag(): Promise { const currentGitBranch = await getCurrentGitBranch() || ""; let tag = currentGitBranch.toUpperCase() + "_DEPLOYED"; + + if (GitProvider.isDeployBeforeMerge()) { + const prInfo = await GitProvider.getPullRequestInfo(); + const targetBranch = prInfo?.targetBranch || process.env.FORCE_TARGET_BRANCH; + if (targetBranch) { + tag = targetBranch.toUpperCase() + "_DEPLOYED"; + } + } + if (process.env?.DEPLOYED_TAG_TEMPLATE && !(process.env?.DEPLOYED_TAG_TEMPLATE || "").includes("$(")) { - tag = process.env?.DEPLOYED_TAG_TEMPLATE.replace("{BRANCH}", currentGitBranch.toUpperCase()); + const branchToUse = tag.replace("_DEPLOYED", ""); + tag = process.env?.DEPLOYED_TAG_TEMPLATE.replace("{BRANCH}", branchToUse); } + return tag; } }