Azure Pipelines templates for MuleSoft: one delivery flow, many applications
- By Bruno Souza
- Delivery
- Updated
- 7 min read
On this page
Code
A team with thirty Mule applications should not have thirty copies of the same pipeline. When the delivery process changes — a new check, a new environment, a fix like the one in the previous article — it should change once, and each application should choose when to pick it up. Azure Pipelines templates give you that, if the repository is structured for it.
To run it in your account: follow the step by step with the sample code, ready for Azure DevOps.
Two repositories
- Templates repository — the delivery process. Versioned with tags (
v1.0.0,v1.0.1,v1.1.0,v1.2.1). - Application repository — the Mule app and a ten-line
azure-pipelines.ymlthat extends a tagged version of the templates.
resources:
repositories:
- repository: templates
type: github
endpoint: github.com_brunosouzas
name: brunosouzas/azure-devops-mulesoft-pipelines
ref: refs/tags/v1.2.1
extends:
template: templates/stages/gitflow.yml@templates
parameters:
nextVersionBump: minor
In the repository: azure-pipelines.yml
Pinning to a tag is the important part. A change to the templates never alters an application’s pipeline until that application moves its ref. During this project the release job was fixed in v1.0.1 and a smoke test added in v1.1.0; the application adopted each one through a normal pull request. Later, the Maven 3.10 on the hosted agent image broke the Mule plugins, and v1.2.1 fixes that, which is why the example pins that tag.
extends rather than template: inside stages: is deliberate: the application cannot add steps before or after the governed flow, which matters when the templates carry controls you want everyone to run.
Step by step: run it in your account
You need a GitHub account, an Anypoint organization with the test, uat and prod environments, and an Azure DevOps organization with a hosted job: in a new organization, enable the free tier first.
1. Copy the code. Fork the sample code and the templates. In both, clear Copy the main branch only: the application needs develop.
2. Prepare Anypoint. Create a Connected App of the type App acts on its own behalf (client credentials), with Exchange Contributor, Design Center Developer, the Runtime Manager deploy scopes and access to the three environments. The deployment parameters are in the MuleSoft documentation.
3. Create the variable group. In Pipelines > Library, create vg-00-anypoint-platform with ANYPOINT_ORG_ID, ANYPOINT_CLIENT_ID and ANYPOINT_CLIENT_SECRET, the last one marked secret.

4. Create the environments. In Pipelines > Environments, create test, uat and prod, and put the approval on prod.
5. Install the GitHub app. Install the Azure Pipelines app with Only select repositories and choose both forks. Use the app, not OAuth.
6. Create the pipeline. In Pipelines > New pipeline, choose GitHub, the application fork and the azure-pipelines.yml already in it. Save without running.

7. Note the connection name. It shows up in Project settings > Service connections. Authorize only the pipelines that will use it.

8. Adjust the code. Clone the fork and make all the changes in a single commit on develop.
| File | What to change |
|---|---|
azure-pipelines.yml |
endpoint: the name of your connection; name: your fork of the templates |
pom.xml |
groupId: your Anypoint organization ID; <scm>: your fork |
deployment/test.yaml, uat.yaml and prod.yaml |
applicationName and target; delete healthUrl until you know your application’s URL |
9. Run it. The push to develop triggers the pipeline. When it asks for permission to use the connection, the group or an environment, permit it. The build, the SNAPSHOT publication and the deployment to test run; release, uat and prod are skipped. The picture shows the same sequence on the circuit breaker demo application.

10. Release a version. Take the change to main through a release/x.y.z branch, as in the GitFlow article: the pipeline releases, deploys to uat and, after the approval, to prod. If main is protected, see who may push.
Layout of the templates
templates/
stages/gitflow.yml entry point: which stages run, from the branch
jobs/ci.yml build and package
jobs/publish-snapshot.yml develop → Exchange
jobs/release.yml Maven release on main
jobs/deploy.yml deploy a version from Exchange to CloudHub 2.0
steps/setup-maven.yml Java 17, Maven cache, settings.xml
docs/adr/ the reasons behind each choice
In the repository: templates/
Stages decide when, jobs decide what, steps are the reusable pieces. Decisions that would otherwise live in someone’s head — why the release runs on main, why nothing is rebuilt per environment — are ADRs next to the code.
Secrets without secure files
Maven needs credentials for Exchange. A common approach stores a whole settings.xml as a secure file. The templates generate it instead, from a variable group, at runtime:
- bash: |
cat > "${SETTINGS_PATH}" <<XML
<settings>
<servers>
<server>
<id>anypoint-exchange-v3</id>
<username>~~~Client~~~</username>
<password>${ANYPOINT_CLIENT_ID}~?~${ANYPOINT_CLIENT_SECRET}</password>
</server>
</servers>
</settings>
XML
env:
ANYPOINT_CLIENT_ID: $(ANYPOINT_CLIENT_ID)
ANYPOINT_CLIENT_SECRET: $(ANYPOINT_CLIENT_SECRET)
In the repository: templates/steps/setup-maven.yml
~~~Client~~~ with clientId~?~clientSecret is how Exchange accepts a Connected App instead of a user. The Connected App needs Exchange Contributor, the Runtime Manager deploy scopes and access to each target environment. The secret lives in the variable group vg-00-anypoint-platform, marked secret, so it is masked in logs — and secret variables have to be mapped into env explicitly, as above.
Why MUnit is not in this pipeline
MUnit runs on the Mule Enterprise runtime, which Maven downloads from MuleSoft’s Enterprise repository. Access to it comes with a customer subscription, and the credentials belong to that customer.
This is a public, personal project. I could have used an employer’s credentials — protected as a secure file, nobody would see them — but that would be using their licence outside their business. So the pipeline builds with -DskipMunitTests, MUnit runs locally before each pull request (mvn clean test, six tests, 100% coverage) and the PR template asks for it. In a company pipeline, the change is two lines: provide the Enterprise repository credentials and remove the flag. ADR 4 records the decision.
It is worth confirming that the rest works without those credentials. Packaging the app with an empty settings.xml and an empty local Maven repository succeeds: only MUnit needs the Enterprise repository.
A misleading MUnit failure
While writing the local tests, the suite refused to deploy. The first error in the log was:
[global.xml:15]: Connection is not secure. Should use `HTTPS`
That is a warning from the HTTP connector’s validations, and it appears in healthy projects too. The real error was on the next line: a test called create-order, the same name as a flow. MUnit tests share the application’s global namespace. Prefix test names (test-create-order) and the suite runs.
Checklist
- Is each application’s pipeline a thin
extendsof a tagged template version? - Can the templates change without silently changing every application?
- Are credentials generated at runtime from secret variables, mapped explicitly into
env? - Are the decisions behind the templates written down next to them?