Skip to content

Publish to environment error preference - #2176

Open
spetersenms wants to merge 12 commits into
microsoft:mainfrom
spetersenms:publishToEnvironmentErrorPreference
Open

Publish to environment error preference#2176
spetersenms wants to merge 12 commits into
microsoft:mainfrom
spetersenms:publishToEnvironmentErrorPreference

Conversation

@spetersenms

@spetersenms spetersenms commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

❔What, Why & How

New error preference setting to allow users to select what should happen if the selected environments in Publish to Environment are all excluded by branch policies or rules. Default and current behavior is to ignore, New options includes a warning, and error which will fail the workflow.

Related to issue: #2147

✅ Checklist

  • Add tests (E2E, unit tests)
  • Update RELEASENOTES.md
  • Update documentation (e.g. for new settings or scenarios)
  • Add telemetry

spetersenms and others added 7 commits April 7, 2026 14:57
…ersenms/AL-Go into publishToEnvironmentErrorPreference
The test piped an array to Should -Match, which in Pester 5 asserts
that every element matches the regex. The first non-matching element
(e.g. GenerateALDocArtifact=1) caused the assertion to fail even
though the warning was correctly emitted.

Fix by joining output with Out-String before matching, so the regex
checks the combined text for the warning message.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…tErrorPreference

# Conflicts:
#	RELEASENOTES.md
#	Scenarios/settings.md
@spetersenms
spetersenms marked this pull request as ready for review September 1, 2026 06:47
@spetersenms
spetersenms requested a review from a team as a code owner September 1, 2026 06:47
Copilot AI balanced review requested due to automatic review settings September 1, 2026 06:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds configurable handling when manual publication finds environments but branch policies exclude them.

Changes:

  • Adds ignore, warning, and error behaviors with tests.
  • Improves branch-policy diagnostics and workflow input logging.
  • Documents the setting and release impact.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Tests/DetermineDeploymentEnvironments.Test.ps1 Tests all behaviors and CD exclusion.
Scenarios/settings.md Documents the setting.
RELEASENOTES.md Announces the behavior.
Actions/DumpWorkflowInfo/DumpWorkflowInfo.ps1 Logs the selected branch.
Actions/DetermineDeploymentEnvironments/DetermineDeploymentEnvironments.ps1 Implements filtering diagnostics and configured outcomes.
Actions/.Modules/settings.schema.json Defines schema validation.
Actions/.Modules/ReadSettings.psm1 Adds the default value.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +597 to +601
"noMatchingEnvironmentsAction": {
"type": "string",
"pattern": "^(ignore|warning|error)$",
"description": "Specifies what happens when deployment environments are found but all are excluded by branch policies or deployment type filters. Allowed values are ignore, warning and error. See https://aka.ms/ALGoSettings#nomatchingenvironmentsaction"
},
Comment on lines +273 to +281
if ($deploymentSettings.BranchesFromPolicy -and $deploymentSettings.BranchesFromPolicy.Count -gt 0) {
Write-Host "Environment $environmentName is not setup for deployments from branch '$($ENV:GITHUB_REF_NAME)' (GitHub policy allows branches: $($deploymentSettings.BranchesFromPolicy -join ', '))"
}
elseif ($deploymentSettings.Branches -and $deploymentSettings.Branches.Count -gt 0) {
Write-Host "Environment $environmentName is not setup for deployments from branch '$($ENV:GITHUB_REF_NAME)' (allowed branches in settings: $($deploymentSettings.Branches -join ', '))"
}
else {
Write-Host "Environment $environmentName is not setup for deployments from branch '$($ENV:GITHUB_REF_NAME)' (no branch policy defined - only 'main' is allowed by default)"
}
spetersenms and others added 2 commits September 1, 2026 09:06
…sage

- Use enum + default (ignore) instead of regex pattern for noMatchingEnvironmentsAction in settings schema

- Report both GitHub policy and settings Branches allowed lists in skip message when both are configured, so the actual rejection reason is not hidden

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The combined branch-message test rendered captured output via Out-String,
which word-wraps long lines at the console width. On the windows-latest
(PS5) runner the wrap split 'GitHub policy allows branches: feature/*'
across a newline, breaking the regex match even though production emits
the correct message. Match against raw joined output lines instead.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Publish To Environment workflow does not log user inputs and reports false success when environments are skipped

2 participants