From 861c6809ce4c98c599666f9873dec1d985eabf41 Mon Sep 17 00:00:00 2001 From: Sathiyakumar Ganesan Date: Wed, 20 May 2026 17:36:17 +0100 Subject: [PATCH 1/8] Refactor default values in apigee-deployment.yml for consistency and clarity --- azure/common/apigee-deployment.yml | 193 ++++++++++++++--------------- 1 file changed, 96 insertions(+), 97 deletions(-) diff --git a/azure/common/apigee-deployment.yml b/azure/common/apigee-deployment.yml index ea11cb34..faaaace5 100644 --- a/azure/common/apigee-deployment.yml +++ b/azure/common/apigee-deployment.yml @@ -23,20 +23,20 @@ parameters: - name: fully_qualified_service_name displayName: Supply a custom name for your release (only valid for release pipeline) type: string - default: '' + default: "" - name: ping displayName: Toggle ping endpoint avaliablility type: boolean default: true - name: hosted_target_connection_path_suffix type: string - default: '' + default: "" - name: hosted_target_healthcheck_suffix type: string - default: '/_status' + default: "/_status" - name: jinja_templates type: object - displayName: Key/values for custom jinja templating + displayName: Key/values for custom jinja templating default: [] - name: enable_monitoring type: boolean @@ -85,7 +85,7 @@ parameters: - name: manual_approval_env displayName: Custom manual approval env overwrite type: string - default: 'manual-approval' + default: "manual-approval" - name: _scoped_pipeline_vars type: object displayName: All the pipeline parameters which support per-environment scoping. @@ -121,12 +121,12 @@ parameters: - name: _pipeline_defaults type: object default: - - name_suffix: '-Pull-Request' + - name_suffix: "-Pull-Request" deploy_template: pr.yml environments: - - internal-dev - - internal-dev-sandbox - - name_suffix: '-Release' + - internal-dev + - internal-dev-sandbox + - name_suffix: "-Release" deploy_template: release.yml environments: - internal-dev @@ -139,15 +139,15 @@ parameters: - prod # Deprecated pipeline variables. - name: product_display_name - default: 'DEPRECATED' + default: "DEPRECATED" - name: product_description - default: 'DEPRECATED' + default: "DEPRECATED" - name: portal_api_requires_callback_url - default: 'DEPRECATED' + default: "DEPRECATED" - name: make_spec_visible - default: 'DEPRECATED' + default: "DEPRECATED" - name: spec_file - default: 'DEPRECATED' + default: "DEPRECATED" - name: python_version type: string default: "3.13" @@ -155,91 +155,90 @@ parameters: type: string default: "AWS-ECS" +stages: + - template: ./deploy-stages.yml + parameters: + ${{ each param in parameters }}: + ${{ if notIn(param.key, 'apigee_deployments', '_scoped_pipeline_vars', '_scoped_step_list_vars', '_pipeline_defaults') }}: + ${{ if not(contains(join(',', parameters._scoped_pipeline_vars), param.key)) }}: + ${{ param.key }}: ${{ param.value }} -extends: - template: ./deploy-stages.yml - parameters: - ${{ each param in parameters }}: - ${{ if notIn(param.key, 'apigee_deployments', '_scoped_pipeline_vars', '_scoped_step_list_vars', '_pipeline_defaults') }}: - ${{ if not(contains(join(',', parameters._scoped_pipeline_vars), param.key)) }}: - ${{ param.key }}: ${{ param.value }} + ${{ each pipeline_default in parameters._pipeline_defaults }}: + ${{ if endsWith(variables['Build.DefinitionName'], pipeline_default.name_suffix) }}: + deploy_template: ${{ pipeline_default.deploy_template }} - ${{ each pipeline_default in parameters._pipeline_defaults }}: - ${{ if endsWith(variables['Build.DefinitionName'], pipeline_default.name_suffix) }}: - deploy_template: ${{ pipeline_default.deploy_template }} + # If apigee_deployments was specified, accept it regardless of which pipeline we are in + ${{ if gt(length(parameters.apigee_deployments), 0) }}: + apigee_deployments: + - ${{ each apigee_deployment in parameters.apigee_deployments }}: + - ${{ if and(eq(apigee_deployment.environment, 'prod'), parameters.prod_requires_approval) }}: + - environment: manual-approval + stage_name: manual_approval + depends_on: [] + manual_approval_prod: true + producer_approval: ${{ parameters.prod_producer_approval }} + ${{ each var in parameters._scoped_pipeline_vars }}: + ${{ var }}: ${{ parameters[var] }} + - ${{ each apigee_deployment in parameters.apigee_deployments }}: + - environment: ${{ apigee_deployment.environment }} + stage_name: ${{ replace(coalesce (apigee_deployment.stage_name, apigee_deployment.environment), '-', '_') }} + ${{ each var in parameters._scoped_pipeline_vars }}: + ${{ if apigee_deployment[var] }}: + ${{ if containsValue(parameters._scoped_step_list_vars, var) }}: + ${{ var }}: + - ${{ each step in apigee_deployment[var] }}: + ${{ each pair in step }}: + # Assume scoped template paths are + # relative to azure/ in @self repo + ${{ if and(eq(pair.key, 'template'), not(contains(pair.value, '@'))) }}: + ${{ pair.key }}: azure/${{ pair.value }}@self + ${{ if not(and(eq(pair.key, 'template'), not(contains(pair.value, '@')))) }}: + ${{ pair.key }}: ${{ pair.value }} + ${{ if not(containsValue(parameters._scoped_step_list_vars, var)) }}: + ${{ var }}: ${{ apigee_deployment[var] }} + ${{ if not(apigee_deployment[var]) }}: + ${{ var }}: ${{ parameters[var] }} + ${{ if not(apigee_deployment.depends_on) }}: + ${{ if or(startsWith(apigee_deployment.environment, 'internal-'), eq(apigee_deployment.environment, 'manual-approval')) }}: + depends_on: [] + ${{ if and(not(startsWith(apigee_deployment.environment, 'internal-')), ne(apigee_deployment.environment, 'manual-approval')) }}: + depends_on: + - internal_qa + - ${{ if and(eq(apigee_deployment.environment, 'prod'), parameters.prod_requires_approval) }}: + - manual_approval + ${{ if apigee_deployment.depends_on }}: + depends_on: + - ${{ each depend_on in apigee_deployment.depends_on }}: + - ${{ depend_on }} + - ${{ if and(eq(apigee_deployment.environment, 'prod'), parameters.prod_requires_approval) }}: + - manual_approval - # If apigee_deployments was specified, accept it regardless of which pipeline we are in - ${{ if gt(length(parameters.apigee_deployments), 0) }}: - apigee_deployments: - - ${{ each apigee_deployment in parameters.apigee_deployments }}: - - ${{ if and(eq(apigee_deployment.environment, 'prod'), parameters.prod_requires_approval) }}: - - environment: manual-approval - stage_name: manual_approval - depends_on: [] - manual_approval_prod: true - producer_approval: ${{ parameters.prod_producer_approval }} - ${{ each var in parameters._scoped_pipeline_vars }}: - ${{ var }}: ${{ parameters[var] }} - - ${{ each apigee_deployment in parameters.apigee_deployments }}: - - environment: ${{ apigee_deployment.environment }} - stage_name: ${{ replace(coalesce (apigee_deployment.stage_name, apigee_deployment.environment), '-', '_') }} - ${{ each var in parameters._scoped_pipeline_vars }}: - ${{ if apigee_deployment[var] }}: - ${{ if containsValue(parameters._scoped_step_list_vars, var) }}: - ${{ var }}: - - ${{ each step in apigee_deployment[var] }}: - ${{ each pair in step }}: - # Assume scoped template paths are - # relative to azure/ in @self repo - ${{ if and(eq(pair.key, 'template'), not(contains(pair.value, '@'))) }}: - ${{ pair.key }}: azure/${{ pair.value }}@self - ${{ if not(and(eq(pair.key, 'template'), not(contains(pair.value, '@')))) }}: - ${{ pair.key }}: ${{ pair.value }} - ${{ if not(containsValue(parameters._scoped_step_list_vars, var)) }}: - ${{ var }}: ${{ apigee_deployment[var] }} - ${{ if not(apigee_deployment[var]) }}: - ${{ var }}: ${{ parameters[var] }} - ${{ if not(apigee_deployment.depends_on) }}: - ${{ if or(startsWith(apigee_deployment.environment, 'internal-'), eq(apigee_deployment.environment, 'manual-approval')) }}: + # otherwise set the default parameters for this pipeline + ${{ if eq(0, length(parameters.apigee_deployments)) }}: + apigee_deployments: + - ${{ each environment in pipeline_default.environments }}: + - ${{ if notIn(environment, 'internal-dev-sandbox') }}: + - environment: ${{ environment }} + stage_name: ${{ replace(environment, '-', '_') }} + ${{ if startsWith(environment, 'internal-') }}: + depends_on: [] + ${{ if not(startsWith(environment, 'internal-')) }}: + depends_on: + - internal_qa + - internal_qa_sandbox + - ${{ if and(parameters.prod_requires_approval, eq(environment, 'prod')) }}: + - manual_approval + ${{ each var in parameters._scoped_pipeline_vars }}: + ${{ var }}: ${{ parameters[var] }} + - ${{ if parameters.deploy_review_sandbox }}: + - environment: internal-dev-sandbox + stage_name: internal_dev_sandbox depends_on: [] - ${{ if and(not(startsWith(apigee_deployment.environment, 'internal-')), ne(apigee_deployment.environment, 'manual-approval')) }}: - depends_on: - - internal_qa - - ${{ if and(eq(apigee_deployment.environment, 'prod'), parameters.prod_requires_approval) }}: - - manual_approval - ${{ if apigee_deployment.depends_on }}: - depends_on: - - ${{ each depend_on in apigee_deployment.depends_on }}: - - ${{ depend_on }} - - ${{ if and(eq(apigee_deployment.environment, 'prod'), parameters.prod_requires_approval) }}: - - manual_approval - - # otherwise set the default parameters for this pipeline - ${{ if eq(0, length(parameters.apigee_deployments)) }}: - apigee_deployments: - - ${{ each environment in pipeline_default.environments }}: - - ${{ if notIn(environment, 'internal-dev-sandbox') }}: - - environment: ${{ environment }} - stage_name: ${{ replace(environment, '-', '_') }} - ${{ if startsWith(environment, 'internal-') }}: + ${{ each var in parameters._scoped_pipeline_vars }}: + ${{ var }}: ${{ parameters[var] }} + - ${{ if and(parameters.prod_requires_approval, containsValue(pipeline_default.environments, 'prod')) }}: + - environment: manual-approval + stage_name: manual_approval depends_on: [] - ${{ if not(startsWith(environment, 'internal-')) }}: - depends_on: - - internal_qa - - internal_qa_sandbox - - ${{ if and(parameters.prod_requires_approval, eq(environment, 'prod')) }}: - - manual_approval - ${{ each var in parameters._scoped_pipeline_vars }}: - ${{ var }}: ${{ parameters[var] }} - - ${{ if parameters.deploy_review_sandbox }}: - - environment: internal-dev-sandbox - stage_name: internal_dev_sandbox - depends_on: [] - ${{ each var in parameters._scoped_pipeline_vars }}: - ${{ var }}: ${{ parameters[var] }} - - ${{ if and(parameters.prod_requires_approval, containsValue(pipeline_default.environments, 'prod')) }}: - - environment: manual-approval - stage_name: manual_approval - depends_on: [] - ${{ each var in parameters._scoped_pipeline_vars }}: - ${{ var }}: ${{ parameters[var] }} + ${{ each var in parameters._scoped_pipeline_vars }}: + ${{ var }}: ${{ parameters[var] }} From 1422f6ba5f4a66a6197ee0522baebdb1bba4a088 Mon Sep 17 00:00:00 2001 From: Sathiyakumar Ganesan Date: Wed, 20 May 2026 18:48:08 +0100 Subject: [PATCH 2/8] Enhance notification logic in deploy-stage.yml and update-github-status.yml for improved commit SHA handling and debugging output --- azure/common/deploy-stage.yml | 37 ++++++++++++++++++++--- azure/components/update-github-status.yml | 6 ++-- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/azure/common/deploy-stage.yml b/azure/common/deploy-stage.yml index fdd45920..242e2141 100644 --- a/azure/common/deploy-stage.yml +++ b/azure/common/deploy-stage.yml @@ -167,11 +167,40 @@ stages: - ${{ if parameters.notify }}: - bash: | - if [[ -z $(NOTIFY_COMMIT_SHA) ]]; then - export NOTIFY_COMMIT_SHA=`echo "$(Build.SourceVersionMessage)" | cut -d' ' -f2` - echo "##vso[task.setvariable variable=NOTIFY_COMMIT_SHA]$NOTIFY_COMMIT_SHA" + echo "Build.SourceBranch: $(Build.SourceBranch)" + echo "Build.SourceVersion: $(Build.SourceVersion)" + echo "Build.SourceVersionMessage: $(Build.SourceVersionMessage)" + echo "System.PullRequest.SourceCommitId: $(System.PullRequest.SourceCommitId)" + + if [[ ! -z $(NOTIFY_COMMIT_SHA) ]]; then + echo "##[debug]Using already provided NOTIFY_COMMIT_SHA=$(NOTIFY_COMMIT_SHA)" else - echo "##[debug]Using already provided NOTIFY_COMMIT_SHA=$(NOTIFY_COMMIT_SHA)" + NOTIFY_COMMIT_SHA="" + + if [[ "$(Build.SourceBranch)" =~ ^refs/pull/.+$ ]]; then + if [[ ! -z "$(System.PullRequest.SourceCommitId)" ]]; then + echo "##[debug]Build appears to be a pull request build" + echo "##[debug]Using System.PullRequest.SourceCommitId as NOTIFY_COMMIT_SHA" + NOTIFY_COMMIT_SHA="$(System.PullRequest.SourceCommitId)" + else + echo "##[debug]Build appears to be a pull request build" + echo "##[debug]Extracting NOTIFY_COMMIT_SHA from Build.SourceVersionMessage" + NOTIFY_COMMIT_SHA=`echo "$(Build.SourceVersionMessage)" | cut -d' ' -f2` + fi + fi + + if [[ "$(Build.SourceBranch)" =~ ^refs/tags/.+$ ]] && [[ -z "$NOTIFY_COMMIT_SHA" ]]; then + echo "##[debug]Build appears to be a tag build" + echo "##[debug]Using Build.SourceVersion as NOTIFY_COMMIT_SHA" + NOTIFY_COMMIT_SHA="$(Build.SourceVersion)" + fi + + if [[ -z "$NOTIFY_COMMIT_SHA" ]]; then + echo "##[debug]Using Build.SourceVersion as NOTIFY_COMMIT_SHA" + NOTIFY_COMMIT_SHA="$(Build.SourceVersion)" + fi + + echo "##vso[task.setvariable variable=NOTIFY_COMMIT_SHA]$NOTIFY_COMMIT_SHA" fi displayName: Set NOTIFY_COMMIT_SHA diff --git a/azure/components/update-github-status.yml b/azure/components/update-github-status.yml index 9d77e925..06951775 100644 --- a/azure/components/update-github-status.yml +++ b/azure/components/update-github-status.yml @@ -33,10 +33,12 @@ steps: export NOTIFY_GITHUB_REPOSITORY=$(Build.Repository.Name) fi - if [[ "$(NOTIFY_COMMIT_SHA)" =~ ^[0-9a-f]+$ ]]; then + BUILD_RESULTS_URL="$(System.CollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&view=results" + + if [[ "$(NOTIFY_COMMIT_SHA)" =~ ^[0-9a-f]+$ ]]; then echo "Reporting state ${{ parameters.state }} to ${NOTIFY_GITHUB_REPOSITORY}" echo "##[debug] Hitting https://api.github.com/repos/${NOTIFY_GITHUB_REPOSITORY}/statuses/$(NOTIFY_COMMIT_SHA)" - curl --fail -q -X POST "https://api.github.com/repos/${NOTIFY_GITHUB_REPOSITORY}/statuses/$(NOTIFY_COMMIT_SHA)" -d '{"state": "${{ parameters.state }}", "context": "$(Build.DefinitionName) $environment", "description": "$description", "target_url": "https://dev.azure.com/NHSD-APIM/API Platform/_build/results?buildId=$(Build.BuildID)"}' --user $(GITHUB_USER):$(GITHUB_ACCESS_TOKEN) + curl --fail -q -X POST "https://api.github.com/repos/${NOTIFY_GITHUB_REPOSITORY}/statuses/$(NOTIFY_COMMIT_SHA)" -d '{"state": "${{ parameters.state }}", "context": "$(Build.DefinitionName) $environment", "description": "$description", "target_url": "'"${BUILD_RESULTS_URL}"'"}' --user $(GITHUB_USER):$(GITHUB_ACCESS_TOKEN) else echo "##[warning]$(NOTIFY_COMMIT_SHA) doesn't look like a commit hash" echo "##[task.logissue type=warning]Task wasn't able to find the right commit sha value to notify github." From c252ad06e39c86cb9a30f8916a75b5ed55c73364 Mon Sep 17 00:00:00 2001 From: Sathiyakumar Ganesan Date: Wed, 20 May 2026 18:56:37 +0100 Subject: [PATCH 3/8] Fix quoting in notify commit SHA handling for improved shell script reliability --- azure/common/deploy-stage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure/common/deploy-stage.yml b/azure/common/deploy-stage.yml index 242e2141..5b2593ba 100644 --- a/azure/common/deploy-stage.yml +++ b/azure/common/deploy-stage.yml @@ -172,7 +172,7 @@ stages: echo "Build.SourceVersionMessage: $(Build.SourceVersionMessage)" echo "System.PullRequest.SourceCommitId: $(System.PullRequest.SourceCommitId)" - if [[ ! -z $(NOTIFY_COMMIT_SHA) ]]; then + if [[ ! -z "$(NOTIFY_COMMIT_SHA)" ]]; then echo "##[debug]Using already provided NOTIFY_COMMIT_SHA=$(NOTIFY_COMMIT_SHA)" else NOTIFY_COMMIT_SHA="" @@ -185,7 +185,7 @@ stages: else echo "##[debug]Build appears to be a pull request build" echo "##[debug]Extracting NOTIFY_COMMIT_SHA from Build.SourceVersionMessage" - NOTIFY_COMMIT_SHA=`echo "$(Build.SourceVersionMessage)" | cut -d' ' -f2` + NOTIFY_COMMIT_SHA=$(echo "$(Build.SourceVersionMessage)" | cut -d' ' -f2) fi fi From cb50322801d15f27e977e696310a11f6d297c6af Mon Sep 17 00:00:00 2001 From: Sathiyakumar Ganesan Date: Wed, 20 May 2026 20:08:07 +0100 Subject: [PATCH 4/8] Enhance GitHub status update logic to use JSON payload for improved API compatibility and readability --- azure/common/deploy-stage.yml | 10 +++++++++- azure/components/update-github-status.yml | 22 +++++++++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/azure/common/deploy-stage.yml b/azure/common/deploy-stage.yml index 5b2593ba..53f8f35b 100644 --- a/azure/common/deploy-stage.yml +++ b/azure/common/deploy-stage.yml @@ -98,6 +98,14 @@ stages: fi displayName: "check workspace is clean" + - bash: | + if [[ -n "$(System.PullRequest.SourceBranch)" ]]; then + echo "##vso[task.setvariable variable=RESOLVED_ARTIFACT_BRANCH]$(System.PullRequest.SourceBranch)" + else + echo "##vso[task.setvariable variable=RESOLVED_ARTIFACT_BRANCH]$(Build.SourceBranch)" + fi + displayName: "Resolve artifact branch" + - task: DownloadPipelineArtifact@2 inputs: source: "specific" @@ -105,7 +113,7 @@ stages: pipeline: $(resources.pipeline.build_pipeline.pipelineID) preferTriggeringPipeline: true runVersion: "latestFromBranch" - runBranch: $(Build.SourceBranch) + runBranch: "$(RESOLVED_ARTIFACT_BRANCH)" path: "$(Pipeline.Workspace)/s/${{ parameters.service_name }}" - bash: | diff --git a/azure/components/update-github-status.yml b/azure/components/update-github-status.yml index 06951775..f3662810 100644 --- a/azure/components/update-github-status.yml +++ b/azure/components/update-github-status.yml @@ -33,12 +33,24 @@ steps: export NOTIFY_GITHUB_REPOSITORY=$(Build.Repository.Name) fi - BUILD_RESULTS_URL="$(System.CollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&view=results" + BUILD_RESULTS_URL="$(System.CollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&view=results" - if [[ "$(NOTIFY_COMMIT_SHA)" =~ ^[0-9a-f]+$ ]]; then - echo "Reporting state ${{ parameters.state }} to ${NOTIFY_GITHUB_REPOSITORY}" - echo "##[debug] Hitting https://api.github.com/repos/${NOTIFY_GITHUB_REPOSITORY}/statuses/$(NOTIFY_COMMIT_SHA)" - curl --fail -q -X POST "https://api.github.com/repos/${NOTIFY_GITHUB_REPOSITORY}/statuses/$(NOTIFY_COMMIT_SHA)" -d '{"state": "${{ parameters.state }}", "context": "$(Build.DefinitionName) $environment", "description": "$description", "target_url": "'"${BUILD_RESULTS_URL}"'"}' --user $(GITHUB_USER):$(GITHUB_ACCESS_TOKEN) + if [[ "$(NOTIFY_COMMIT_SHA)" =~ ^[0-9a-f]+$ ]]; then + echo "Reporting state ${{ parameters.state }} to ${NOTIFY_GITHUB_REPOSITORY}" + echo "##[debug] Hitting https://api.github.com/repos/${NOTIFY_GITHUB_REPOSITORY}/statuses/$(NOTIFY_COMMIT_SHA)" + + payload=$(jq -nc \ + --arg state "${{ parameters.state }}" \ + --arg context "$(Build.DefinitionName) ${environment}" \ + --arg description "${description}" \ + --arg target_url "${BUILD_RESULTS_URL}" \ + '{state: $state, context: $context, description: $description, target_url: $target_url}') + + curl --fail -q \ + -H "Accept: application/vnd.github+json" \ + -X POST "https://api.github.com/repos/${NOTIFY_GITHUB_REPOSITORY}/statuses/$(NOTIFY_COMMIT_SHA)" \ + -d "${payload}" \ + --user $(GITHUB_USER):$(GITHUB_ACCESS_TOKEN) else echo "##[warning]$(NOTIFY_COMMIT_SHA) doesn't look like a commit hash" echo "##[task.logissue type=warning]Task wasn't able to find the right commit sha value to notify github." From 999f3e3334cd41aba01f716fe1dca8cc57eac29a Mon Sep 17 00:00:00 2001 From: Sathiyakumar Ganesan Date: Fri, 22 May 2026 14:17:24 +0100 Subject: [PATCH 5/8] Remove artifact branch resolution logic and use Build.SourceBranch directly --- azure/common/deploy-stage.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/azure/common/deploy-stage.yml b/azure/common/deploy-stage.yml index 53f8f35b..5b2593ba 100644 --- a/azure/common/deploy-stage.yml +++ b/azure/common/deploy-stage.yml @@ -98,14 +98,6 @@ stages: fi displayName: "check workspace is clean" - - bash: | - if [[ -n "$(System.PullRequest.SourceBranch)" ]]; then - echo "##vso[task.setvariable variable=RESOLVED_ARTIFACT_BRANCH]$(System.PullRequest.SourceBranch)" - else - echo "##vso[task.setvariable variable=RESOLVED_ARTIFACT_BRANCH]$(Build.SourceBranch)" - fi - displayName: "Resolve artifact branch" - - task: DownloadPipelineArtifact@2 inputs: source: "specific" @@ -113,7 +105,7 @@ stages: pipeline: $(resources.pipeline.build_pipeline.pipelineID) preferTriggeringPipeline: true runVersion: "latestFromBranch" - runBranch: "$(RESOLVED_ARTIFACT_BRANCH)" + runBranch: $(Build.SourceBranch) path: "$(Pipeline.Workspace)/s/${{ parameters.service_name }}" - bash: | From eb3913dfa4770b1134af3b01fa6d0842f4f98912 Mon Sep 17 00:00:00 2001 From: Sathiyakumar Ganesan Date: Fri, 22 May 2026 14:33:45 +0100 Subject: [PATCH 6/8] Add stage_name parameter to GitHub status update for better context --- azure/common/deploy-stage.yml | 3 +++ azure/components/update-github-status.yml | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/azure/common/deploy-stage.yml b/azure/common/deploy-stage.yml index 5b2593ba..54b63afc 100644 --- a/azure/common/deploy-stage.yml +++ b/azure/common/deploy-stage.yml @@ -209,6 +209,7 @@ stages: state: pending description: "Deploy to ${{ parameters.environment }} started" environment: ${{ parameters.environment }} + stage_name: ${{ parameters.stage_name }} - ${{ each param in parameters }}: - ${{ if not(containsValue(parameters._expose_blacklist, param.key)) }}: @@ -319,6 +320,7 @@ stages: on_success: true description: "Deploy to ${{ parameters.environment }} succeeded" environment: ${{ parameters.environment }} + stage_name: ${{ parameters.stage_name }} - template: "../components/update-github-status.yml" parameters: @@ -326,3 +328,4 @@ stages: on_failure: true description: "Deploy to ${{ parameters.environment }} failed" environment: ${{ parameters.environment }} + stage_name: ${{ parameters.stage_name }} diff --git a/azure/components/update-github-status.yml b/azure/components/update-github-status.yml index f3662810..192bea85 100644 --- a/azure/components/update-github-status.yml +++ b/azure/components/update-github-status.yml @@ -14,6 +14,10 @@ parameters: displayName: Apigee environment deploying against type: string default: "" + - name: stage_name + displayName: Azure stage name for unique status context + type: string + default: "" # Been through a lot of pain to try to get these next two to work. Unfortunately due to how templates # are expanded, flagging like this is the only way I could find to get it to evaluate properly - name: on_success @@ -36,12 +40,17 @@ steps: BUILD_RESULTS_URL="$(System.CollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&view=results" if [[ "$(NOTIFY_COMMIT_SHA)" =~ ^[0-9a-f]+$ ]]; then + context_suffix="${environment}" + if [[ -n "${stage_name}" ]]; then + context_suffix="${environment}/${stage_name}" + fi + echo "Reporting state ${{ parameters.state }} to ${NOTIFY_GITHUB_REPOSITORY}" echo "##[debug] Hitting https://api.github.com/repos/${NOTIFY_GITHUB_REPOSITORY}/statuses/$(NOTIFY_COMMIT_SHA)" payload=$(jq -nc \ --arg state "${{ parameters.state }}" \ - --arg context "$(Build.DefinitionName) ${environment}" \ + --arg context "$(Build.DefinitionName) ${context_suffix}" \ --arg description "${description}" \ --arg target_url "${BUILD_RESULTS_URL}" \ '{state: $state, context: $context, description: $description, target_url: $target_url}') @@ -58,6 +67,7 @@ steps: env: description: ${{ parameters.description }} environment: ${{ parameters.environment }} + stage_name: ${{ parameters.stage_name }} displayName: "Notify GitHub: ${{ parameters.state }}" condition: | or( From 3190d14474d83123a9ece73b046d17244a6edf25 Mon Sep 17 00:00:00 2001 From: Sathiyakumar Ganesan Date: Fri, 22 May 2026 14:55:27 +0100 Subject: [PATCH 7/8] Enhance GitHub status context formatting with environment and stage name brackets --- azure/components/update-github-status.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure/components/update-github-status.yml b/azure/components/update-github-status.yml index 192bea85..6e0fb5e7 100644 --- a/azure/components/update-github-status.yml +++ b/azure/components/update-github-status.yml @@ -40,9 +40,9 @@ steps: BUILD_RESULTS_URL="$(System.CollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&view=results" if [[ "$(NOTIFY_COMMIT_SHA)" =~ ^[0-9a-f]+$ ]]; then - context_suffix="${environment}" + context_suffix="[${environment}]" if [[ -n "${stage_name}" ]]; then - context_suffix="${environment}/${stage_name}" + context_suffix="[${environment}][${stage_name}]" fi echo "Reporting state ${{ parameters.state }} to ${NOTIFY_GITHUB_REPOSITORY}" @@ -50,7 +50,7 @@ steps: payload=$(jq -nc \ --arg state "${{ parameters.state }}" \ - --arg context "$(Build.DefinitionName) ${context_suffix}" \ + --arg context "$(Build.DefinitionName)${context_suffix}" \ --arg description "${description}" \ --arg target_url "${BUILD_RESULTS_URL}" \ '{state: $state, context: $context, description: $description, target_url: $target_url}') From 008394ab34deebae923835dac34cfb9bed10bac5 Mon Sep 17 00:00:00 2001 From: Sathiyakumar Ganesan Date: Fri, 22 May 2026 15:05:01 +0100 Subject: [PATCH 8/8] Refactor GitHub status context naming to include environment and stage name for improved clarity --- azure/components/update-github-status.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/azure/components/update-github-status.yml b/azure/components/update-github-status.yml index 6e0fb5e7..9added39 100644 --- a/azure/components/update-github-status.yml +++ b/azure/components/update-github-status.yml @@ -39,10 +39,14 @@ steps: BUILD_RESULTS_URL="$(System.CollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&view=results" + if [[ "$(NOTIFY_COMMIT_SHA)" =~ ^[0-9a-f]+$ ]]; then - context_suffix="[${environment}]" - if [[ -n "${stage_name}" ]]; then - context_suffix="[${environment}][${stage_name}]" + if [[ -n "${environment}" && -n "${stage_name}" ]]; then + context_name="$(Build.DefinitionName)[${environment}][${stage_name}]" + elif [[ -n "${environment}" ]]; then + context_name="$(Build.DefinitionName)[${environment}]" + else + context_name="$(Build.DefinitionName)" fi echo "Reporting state ${{ parameters.state }} to ${NOTIFY_GITHUB_REPOSITORY}" @@ -50,7 +54,7 @@ steps: payload=$(jq -nc \ --arg state "${{ parameters.state }}" \ - --arg context "$(Build.DefinitionName)${context_suffix}" \ + --arg context "$context_name" \ --arg description "${description}" \ --arg target_url "${BUILD_RESULTS_URL}" \ '{state: $state, context: $context, description: $description, target_url: $target_url}')