MSBA-353 · Lesson 8 of 12 · 19 min

Source control and pipelines

▶ Video coming soon A video version of this lesson is on the way.

Until October, the CF Roastery extension lived in a folder on Noor's laptop and in a shared drive copy that she updated "most days". When Joss Varga-Mbatha, the junior developer Noor was mentoring on the warranty extension in MSBA-352, AL Development for Business Central, started helping with the Tidewell work, the folder approach broke within a day: Joss's change to the setup page and Noor's change to the rate client both touched the same file, and the copy on the shared drive had neither. Quarrystone's ALM lead had been asking for months that every customer project move to GitHub with AL-Go. CF Roastery became the first; the warranty extension from MSBA-352 was planned to follow before go-live. This lesson covers source control for AL projects, the AL-Go for GitHub templates, and the pipeline that now builds, tests and deploys every change.

The MB-820 outline places this work in the development environment domain, with skills such as manage configuration files for an AL extension, manage AL extensions within a workspace, enable code analysis, deploy an extension and maintain extensions. Source control and pipelines are how teams do all of those reliably. MSBA-160 and MSBA-300 cover Git, GitHub and GitHub Actions in depth; here the focus is what is specific to Business Central.

What goes into the repository

An AL repository holds everything needed to build the apps from scratch, and nothing that can be regenerated or that belongs to one person. Noor's first commit set the structure that AL-Go expects: one folder per app, each with its app.json, source files organized by feature, translation files and permission sets; a folder for the test app; and AL-Go's own settings and workflow files.

What belongs in an AL repository.
ItemIn the repository?Why
AL source files, app.json, permission sets, XLIFF translation filesYesThey are the app
Test app sourceYesTests change with the code
Code analysis ruleset fileYesEvery build applies the same rules
.alpackages folder of downloaded symbolsNoRegenerated by downloading symbols; listed in .gitignore
Compiled .app filesNoProduced by the pipeline as build artifacts
A developer's launch.json with a personal sandboxUsually noPersonal settings; AL-Go can create shared ones
Secrets: API keys, client secretsNeverStored in GitHub secrets or Azure Key Vault

Branches follow GitHub flow. The main branch always holds code that could be released. Each change starts on a short-lived feature branch, such as tidewell-parcels, and returns through a pull request that another developer reviews. Branch protection on main requires the pull request build to pass and one approval before merging, so nobody, including Noor, can push untested code straight to main. Commit messages and pull request descriptions name the work item, so that six months later Callum can find why a field was added.

Code analysis

The AL compiler can run code analyzers that check rules beyond syntax. CodeCop enforces Microsoft's AL coding guidelines; UICop checks rules for the web client; PerTenantExtensionCop applies rules specific to per-tenant extensions, such as ID ranges and naming; AppSourceCop applies the much stricter rules for Marketplace apps, including breaking-change checks against previous versions. Developers enable them in the workspace settings under al.codeAnalyzers, and a ruleset file raises, lowers or suppresses individual rules for the project, with a written reason. Enabling code analysis is a named MB-820 skill, and it is cheaper to fix a warning in the editor than a rejection in validation.

Workspace settings that turn on three analyzers and a shared ruleset.
{
  "al.codeAnalyzers": [
    "${CodeCop}",
    "${UICop}",
    "${PerTenantExtensionCop}"
  ],
  "al.ruleSetPath": "../cfroastery.ruleset.json",
  "al.enableCodeAnalysis": true
}

AL-Go for GitHub

AL-Go for GitHub is Microsoft's set of GitHub templates and actions for Business Central DevOps. A new repository is created from one of two templates: AL-Go-PTE for per-tenant extensions, or AL-Go-AppSource for Marketplace apps. The template brings a set of GitHub Actions workflows and settings files. Because the workflows are maintained by Microsoft, a repository stays current by running the Update AL-Go System Files workflow, which pulls in the latest versions, typically through a pull request that the team reviews.

A pipeline drawing. A developer pushes a feature branch and opens a pull request. The Pull Request Build workflow compiles the apps in a container, runs code analysis and the test app, and reports a status check. After review and merge to main, the CI/CD workflow builds again, produces app artifacts and deploys continuously to the CONFIG environment. Later, the Create Release workflow tags a version, and the Publish To Environment workflow deploys that release to PROD after approval.
From pull request to CONFIG automatically, and to PROD by release and approval.
AL-Go workflows used for CF Roastery.
WorkflowWhat it doesWhen CF Roastery uses it
Pull Request BuildBuilds and tests the changes in a pull requestEvery pull request; required by branch protection
CI/CDBuilds main, runs tests, produces artifacts and deploys to environments set for continuous deploymentEvery merge to main; deploys to CONFIG
Create ReleaseCreates a GitHub release with app files and a version tag, optionally incrementing the versionBefore each production deployment
Publish To EnvironmentDeploys a chosen build or release to a chosen environmentDeploying a release to PROD
Test Current, Test Next Minor, Test Next MajorBuilds and tests against current, next minor and next major Business Central versionsScheduled, to catch breaking changes before Microsoft's updates
Update AL-Go System FilesUpdates the repository's AL-Go workflows and scriptsMonthly, through a reviewed pull request
Create a new app, Create a new test appAdds an app folder with the right settingsWhen a second app is added

Settings

AL-Go reads settings from several JSON files and GitHub variables, with a fixed order of precedence: organization-level settings first, then repository settings in .github/AL-Go-Settings.json, then project settings in .AL-Go/settings.json, then workflow-specific and user-specific files, with the last applied winning. Common settings include country, which sets the localization of the build container; appFolders and testFolders; repoVersion, the major and minor version of the apps; enableCodeCop and enableUICop; rulesetFile; and deployment settings for each environment.

Repository settings for CF Roastery: continuous deployment to CONFIG, manual deployment to PROD.
{
  "type": "PTE",
  "repoVersion": "1.3",
  "appFolders": [ "CF Roastery" ],
  "testFolders": [ "CF Roastery Tests" ],
  "enableCodeCop": true,
  "enableUICop": true,
  "rulesetFile": "cfroastery.ruleset.json",
  "environments": [ "CONFIG", "PROD" ],
  "DeployToCONFIG": { "EnvironmentType": "SaaS", "ContinuousDeployment": true, "Branches": [ "main" ] },
  "DeployToPROD": { "EnvironmentType": "SaaS", "ContinuousDeployment": false }
}

The listing leaves out one important setting, country, which Noor set to us, for the US localization that Corbel & Finch uses, so the container used for builds and tests contains the same localized base application as the customer's environments.

Secrets and authentication

To deploy, the workflows must sign in to Business Central. AL-Go reads an authentication context for each environment from a secret named after the environment, such as CONFIG_AUTHCONTEXT and PROD_AUTHCONTEXT, or a general AuthContext secret. The context usually describes a Microsoft Entra application with a client ID and secret, registered in Business Central on the Microsoft Entra Applications page from lesson 1 with permissions to deploy extensions. Other secrets have fixed roles: GhTokenWorkflow lets the update workflow change workflow files; AppSourceContext holds credentials for delivering Marketplace apps through Partner Center; StorageContext points at Azure storage for build artifacts; an Application Insights connection string can be injected at build time. Secrets can live in GitHub or in an Azure Key Vault that AL-Go reads through an AZURE_CREDENTIALS secret, which Quarrystone preferred so all customer secrets sit in one audited vault.

GitHub environments and approvals

Each Business Central environment is also a GitHub environment in the repository's settings. Environments can carry protection rules: required reviewers, wait timers and allowed branches. Noor set PROD to require approval from two people, herself and Quarrystone's ALM lead, and to allow deployment only from main. When someone runs Publish To Environment for PROD, the job waits until both approve, and the approval is recorded with the run. That gives Bettina an audit trail of who released what to her production company and when, which mattered to her more than any technical detail.

Builds, containers and versions

Each build runs on a runner, a machine that executes the workflow. GitHub-hosted runners work for most projects; self-hosted runners give more control or more power. Inside the runner, AL-Go creates a Business Central environment for compiling and testing, traditionally a container created with the BcContainerHelper PowerShell module, and installs the apps, the Test Toolkit and the test app, then runs the tests and collects results. Microsoft has announced that it is phasing out BcContainerHelper in AL-Go for GitHub, with official support ending on October 1, 2027, so the build tooling inside AL-Go will change; the Update AL-Go System Files workflow is how repositories receive those changes.

Every build produces apps with a four-part version: the major.minor from repoVersion, and build and revision numbers from the workflow run. A release is a tagged set of app files that can be deployed again later, which matters when a problem appears and the team needs to know exactly which code is in PROD. The Create Release workflow writes release notes from the merged pull requests and can increment the version for the next cycle.

Worked problem

A change from branch to CONFIG

Joss adds a "Parcels" FactBox to the posted sales shipment page. Walk the change through the pipeline.

Show solution
  1. Joss creates the branch shipment-parcels-factbox, writes the page extension and a UI test, and opens a pull request.
  2. Pull Request Build compiles both apps with CodeCop and UICop, runs all tests in a container, and reports a status check. A UICop warning about a missing ToolTip fails the build; Joss adds it and pushes again.
  3. Noor reviews the code and approves. Branch protection allows the merge.
  4. CI/CD builds main, runs the tests again, saves the app files as artifacts, and deploys to CONFIG because ContinuousDeployment is true there.
  5. Callum tests the FactBox in CONFIG. It waits for the next release to reach PROD.

Answer: Branch, pull request build with analyzers and tests, review, merge, automatic CI/CD deployment to CONFIG, and release to PROD later.

Testing ahead of Microsoft's updates

Lesson 6 noted that each Business Central update recompiles extensions. AL-Go's Test Next Minor and Test Next Major workflows build and test the apps against Microsoft's upcoming versions, using preview artifacts, on a schedule. When the April 2027 major version appears in preview, CF Roastery will be tested against it weeks before any environment updates. A failure there becomes a work item, not an emergency. For Marketplace apps, the same practice is essential, because validation checks every supported version, as lesson 10 explains.

Azure DevOps and other options

AL-Go is not the only route. Many partners use Azure DevOps pipelines, often with Microsoft's or community scripts built on the same container tooling, and some combine Azure DevOps boards with GitHub repositories. The principles do not change: source in Git, pull requests with required builds, analyzers on, tests in containers, versioned artifacts, approved deployments and secrets in a vault. Quarrystone chose AL-Go because Microsoft maintains the workflows, so a small partner does not have to.

Translations and the repository

Business Central uses XLIFF files for translations. With the TranslationFile feature turned on in app.json, every build generates a source file listing all captions, tooltips and labels, and translators produce a file per language. Corbel & Finch works in English, so CF Roastery ships only the generated file, but the habit matters for products: lesson 12's Marketplace app ships French translations, and the pipeline fails if the generated file changes without the translated files being updated. Keeping both in the repository lets reviewers see in a pull request when a caption changed.

Reviewing AL code

Pull request reviews at Quarrystone follow a short checklist so they do not depend on mood. Does every new table field have a data classification? Are captions and tooltips present and clear? Are new public procedures really needed, or can they be internal? Does code read only the fields it needs? Is there a test for the change, and for a bug fix, a test that failed before it? Are events raised in the right place, with names that other developers will understand? Are there any secrets, URLs or customer data in the code? The reviewer comments on the line; the author fixes or explains. Callum, though not a developer, began reading pull request descriptions for CF Roastery, which gave him an early view of every change heading to his environments.

Branches and tags in the CF Roastery repository.
Branch or tagPurposeDeploys to
mainIntegrated, tested codeCONFIG, automatically
Feature branchesOne change each, short-livedNothing; pull request build only
Release tags such as v1.3.0Fixed sets of app filesPROD, by Publish To Environment
Release branches for hotfixesFixes to a version already in PRODPROD after approval

The final piece is documentation in the repository itself: a README that explains how to set up a developer sandbox, which secrets the pipeline needs and who approves production deployments. When Joss joined, she was building and testing within an hour, which was the best argument Noor had for the whole setup.

Common mistakes

  • MistakeCommitting the .alpackages folder or compiled apps.

    InsteadIgnore them in .gitignore; the pipeline produces app files as artifacts.

  • MistakeStoring deployment credentials in a settings file.

    InsteadUse GitHub secrets or Azure Key Vault, such as PROD_AUTHCONTEXT.

  • MistakeDeploying to production from a developer's machine.

    InsteadDeploy a release through Publish To Environment with required approvals.

  • MistakeNever running Update AL-Go System Files.

    InsteadUpdate regularly through a reviewed pull request, especially as build tooling changes.

  • MistakeTurning off analyzers to get a build through.

    InsteadFix the rule or suppress it in the ruleset with a written reason.

Summary and key terms

  • AL repositories hold source, tests, translations, rulesets and AL-Go settings; symbols, compiled apps and secrets stay out.
  • GitHub flow with branch protection requires a passing pull request build and a review before merging.
  • CodeCop, UICop, PerTenantExtensionCop and AppSourceCop are enabled through al.codeAnalyzers and tuned with a ruleset.
  • AL-Go for GitHub provides PTE and AppSource templates with workflows such as CI/CD, Pull Request Build, Create Release and Publish To Environment.
  • Settings files layer by precedence; authentication contexts and other secrets live in GitHub or Azure Key Vault.
  • GitHub environments add approvals to production deployments; Test Next Minor and Next Major catch breaking changes early.
AL-Go for GitHub
Microsoft's GitHub templates and actions for Business Central DevOps.
Code analyzer
A compiler extension such as CodeCop or AppSourceCop that checks rules beyond syntax.
Ruleset file
A JSON file that changes the severity of analyzer rules for a project.
Authentication context
The secret AL-Go uses to sign in to a Business Central environment for deployment.
Continuous deployment
Automatic deployment of successful builds of main to an environment.
Runner
The machine that executes a GitHub Actions workflow.
Branch protection
Rules that require checks and reviews before changes reach a branch.

Practice problems

Work each problem on paper first, then reveal the answer to check.

  1. Why does PROD have ContinuousDeployment set to false?

    Show answer

    So production deployments happen only from a release through Publish To Environment with approvals.

  2. What does the Update AL-Go System Files workflow do?

    Show answer

    It updates the repository's AL-Go workflows and scripts to the latest version, usually through a pull request.

  3. Which analyzer would Quarrystone add for a Marketplace app that it does not use for CF Roastery?

    Show answer

    AppSourceCop.

Lesson quiz · 5 questions

Score 60% or more to complete this lesson.

Take the quiz