1. Define the release stages
- Change review: Pull or merge request checks run on proposed code. Keep deployment credentials unavailable to untrusted contributions.
- Build and test: Use the project Maven Wrapper and a Java version supported by the app's Mule runtime. Run MUnit and other configured tests.
- Scan and package: Check dependencies, secrets, and policy; create the Mule application JAR once. Record its commit and SHA-256 digest.
- Deploy to a lower environment: Deploy the built artifact to development or test and run integration tests against real dependencies where safe.
- Approve production: Present the commit, artifact digest, test results, change record, and rollback plan to an authorized reviewer.
- Deploy and observe: Promote the same JAR to production, run smoke checks, watch health and error rates, and roll back to the last known-good artifact if needed.
2. Prepare the Mule Maven project
Pin the Mule Maven Plugin and runtime versions to versions supported by the application and deployment target. The plugin must have <extensions>true</extensions>. Keep target-specific values such as Anypoint environment, target, application name, and runtime in reviewed Maven profiles or deployment configuration; keep credentials out of the POM.
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-maven-plugin</artifactId>
<version>${mule.maven.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<!-- Add the documented deployment strategy for your target. -->
</configuration>
</plugin>
For CloudHub, CloudHub 2.0, or Runtime Fabric, configure the matching deployment strategy using the current MuleSoft reference. The Maven profile selects non-secret target settings; the runner supplies credentials from its protected secret store. CloudHub 2.0's Mule Maven deployment also requires the application to be published in Exchange and the Mule Maven Facade API configured in Maven distribution management. Confirm target-specific prerequisites for other runtimes, and avoid mutable SNAPSHOT assets in production.
3. Build once, then deploy that artifact
Run the verification lifecycle once. Archive and checksum the resulting *-mule-application.jar; do not rebuild it for staging or production.
# Verify and package the Mule app, including configured MUnit tests
./mvnw -B -ntp clean verify
# After promotion approval, deploy the archived JAR using the target profile
./mvnw -B -ntp -Pproduction mule:deploy \
-Dmule.artifact=dist/customer-api.jar
mule:deploy deploys a prebuilt artifact. The exact Maven profile and artifact path depend on the project's POM and runtime target; validate them in a non-production environment first.
4. Match the runner to the repository
| Source repository | Practical fit for these runners | Important setup |
|---|---|---|
| GitHub | GitHub Actions is native. Jenkins and Azure Pipelines can also connect to GitHub. | Use protected branches and a protected production environment; restrict the GitHub App or runner integration to required repositories. |
| GitLab | GitLab CI is native. Among the three options here, Jenkins is usually the most direct; GitHub Actions or Azure Pipelines needs an explicit supported integration, event relay, or controlled mirror. | Verify webhook delivery, checkout identity, merge-request status reporting, and protected-branch behavior before adopting a bridge or mirror. |
| Bitbucket Cloud | Jenkins or Azure Pipelines can consume it. GitHub Actions needs an event bridge or controlled mirror because the source is outside GitHub. | Use deployment permissions and branch restrictions at the source host as well as the runner's production gate. |
Keep the runner definition with the code where possible: .github/workflows/, a repository Jenkinsfile, or azure-pipelines.yml. If the repo host and runner differ, test that a failed validation blocks merge and that production can only deploy the approved commit.
5. GitHub Actions
Use pull requests for verification and a version tag for the release candidate. Put production deployment in a separate job that references the protected production environment. Configure required reviewers, allowed branches or tags, and environment secrets in repository settings, not only in YAML.
name: MuleSoft release
on:
pull_request:
branches: [main]
push:
branches: [main]
tags: ["v*"]
permissions:
contents: read
jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4 # Pin vetted actions to full SHAs in production.
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "${{ vars.MULE_JAVA_VERSION }}"
- run: ./mvnw -B -ntp clean verify
- run: |
mkdir -p dist
cp target/*-mule-application.jar dist/customer-api.jar
sha256sum dist/customer-api.jar
- uses: actions/upload-artifact@v4
with:
name: mule-app
path: dist/customer-api.jar
staging:
needs: verify
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
environment: staging
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "${{ vars.MULE_JAVA_VERSION }}"
server-id: anypoint-deploy
server-username: ANYPOINT_USERNAME
server-password: ANYPOINT_PASSWORD
env:
ANYPOINT_USERNAME: ${{ secrets.ANYPOINT_USERNAME }}
ANYPOINT_PASSWORD: ${{ secrets.ANYPOINT_PASSWORD }}
- uses: actions/download-artifact@v4
with:
name: mule-app
path: dist
- name: Deploy same artifact to staging
run: ./mvnw -B -ntp -Pstaging mule:deploy -Dmule.artifact=dist/customer-api.jar
- name: Smoke test
env:
APP_URL: ${{ vars.STAGING_HEALTH_URL }}
run: curl --fail --retry 5 --retry-delay 5 "$APP_URL"
production:
if: startsWith(github.ref, 'refs/tags/v')
needs: staging
environment: production
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "${{ vars.MULE_JAVA_VERSION }}"
server-id: anypoint-deploy
server-username: ANYPOINT_USERNAME
server-password: ANYPOINT_PASSWORD
env:
ANYPOINT_USERNAME: ${{ secrets.ANYPOINT_USERNAME }}
ANYPOINT_PASSWORD: ${{ secrets.ANYPOINT_PASSWORD }}
- uses: actions/download-artifact@v4
with:
name: mule-app
path: dist
- name: Deploy approved artifact
run: ./mvnw -B -ntp -Pproduction mule:deploy -Dmule.artifact=dist/customer-api.jar
The setup-java inputs write the protected environment credentials to a Maven server entry named anypoint-deploy; configure the Mule Maven deployment profile to use that server ID. Define MULE_JAVA_VERSION and STAGING_HEALTH_URL as non-secret variables. Do not expose deployment credentials to pull-request jobs. For external GitLab or Bitbucket repositories, add and test the event and checkout integration before relying on this workflow.
6. Jenkins
Use a multibranch Pipeline or webhook to validate changes from GitHub, GitLab, or Bitbucket. Store the Maven settings file as a Jenkins folder-scoped Secret file credential. Restrict the production input to a release group, and protect the Jenkinsfile and job configuration so a code change cannot remove the gate.
pipeline {
agent any
options { timestamps(); disableConcurrentBuilds() }
stages {
stage('Verify and package') {
steps {
sh './mvnw -B -ntp clean verify'
sh 'mkdir -p dist && cp target/*-mule-application.jar dist/customer-api.jar'
stash name: 'mule-app', includes: 'dist/customer-api.jar'
archiveArtifacts artifacts: 'dist/customer-api.jar', fingerprint: true
}
}
stage('Deploy to staging') {
when { branch 'main' }
steps {
unstash 'mule-app'
withCredentials([file(credentialsId: 'maven-settings-staging', variable: 'MAVEN_SETTINGS')]) {
sh './mvnw -s "$MAVEN_SETTINGS" -B -ntp -Pstaging mule:deploy -Dmule.artifact=dist/customer-api.jar'
}
sh 'curl --fail --retry 5 --retry-delay 5 "$STAGING_HEALTH_URL"'
}
}
stage('Production approval') {
when { buildingTag() }
steps { input message: 'Promote the tested JAR to production?', submitter: 'release-managers' }
}
stage('Deploy to production') {
when { buildingTag() }
steps {
unstash 'mule-app'
withCredentials([file(credentialsId: 'maven-settings-production', variable: 'MAVEN_SETTINGS')]) {
sh './mvnw -s "$MAVEN_SETTINGS" -B -ntp -Pproduction mule:deploy -Dmule.artifact=dist/customer-api.jar'
}
sh 'curl --fail --retry 5 --retry-delay 5 "$PRODUCTION_HEALTH_URL"'
}
}
}
}
Install and configure the Pipeline, Credentials Binding, and Pipeline Input Step plugins used by this example. The input step is an operational gate, not a substitute for protecting who can edit the Jenkinsfile, credentials, and job settings.
7. Azure Pipelines
Azure Pipelines supports YAML pipelines with GitHub and Bitbucket Cloud repositories. Add an approval check to the production Environment in Azure DevOps settings; resource checks are managed outside YAML, so a pipeline edit cannot remove them. For Azure Repos, enforce pull-request validation with branch policies; for GitHub or Bitbucket, configure the provider connection and verify the PR trigger.
trigger:
branches:
include: [main]
tags:
include: ["v*"]
stages:
- stage: Verify
jobs:
- job: Build
pool:
vmImage: ubuntu-latest
steps:
- checkout: self
- script: ./mvnw -B -ntp clean verify
displayName: Verify and package Mule app
- script: |
mkdir -p "$(Build.ArtifactStagingDirectory)"
cp target/*-mule-application.jar "$(Build.ArtifactStagingDirectory)/customer-api.jar"
sha256sum "$(Build.ArtifactStagingDirectory)/customer-api.jar"
displayName: Stage immutable artifact
- publish: $(Build.ArtifactStagingDirectory)
artifact: mule-app
- stage: Staging
dependsOn: Verify
jobs:
- deployment: DeployStaging
environment: Mule-Staging
strategy:
runOnce:
deploy:
steps:
- checkout: self
- download: current
artifact: mule-app
- task: DownloadSecureFile@1
name: mavenSettings
inputs:
secureFile: maven-settings-staging.xml
- script: ./mvnw -s "$(mavenSettings.secureFilePath)" -B -ntp -Pstaging mule:deploy -Dmule.artifact="$(Pipeline.Workspace)/mule-app/customer-api.jar"
displayName: Deploy same artifact to staging
- script: curl --fail --retry 5 --retry-delay 5 "$(STAGING_HEALTH_URL)"
displayName: Verify staging health
- stage: Production
dependsOn: Staging
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
jobs:
- deployment: DeployProduction
environment: Mule-Production
strategy:
runOnce:
deploy:
steps:
- checkout: self
- download: current
artifact: mule-app
- task: DownloadSecureFile@1
name: mavenSettings
inputs:
secureFile: maven-settings-production.xml
- script: ./mvnw -s "$(mavenSettings.secureFilePath)" -B -ntp -Pproduction mule:deploy -Dmule.artifact="$(Pipeline.Workspace)/mule-app/customer-api.jar"
displayName: Promote approved artifact to production
- script: curl --fail --retry 5 --retry-delay 5 "$(PRODUCTION_HEALTH_URL)"
displayName: Verify production health
Configure required approval, branch control, and an exclusive lock on the Mule-Production Environment in Azure DevOps. The production settings file is downloaded only for that protected deployment job and removed when the job ends. Keep credentials in Secure Files, a protected variable group, or an approved secret provider, never in YAML.
8. Make the human approval meaningful
Place the approval after staging tests and before production credentials become available. Give reviewers the artifact digest, source commit or tag, MUnit and integration-test results, scan results, deployment target, expected impact, and rollback command. Prevent self-approval where the platform supports it; record who approved and when.
- GitHub Actions: Protect the production Environment with required reviewers and deployment branch/tag rules. Environment secrets are withheld until its protection rules pass. Check plan availability for private repositories.
- Jenkins: Use the Pipeline
inputstep with an explicitsubmitter; protect the job and Jenkinsfile with separate permissions. Jenkins administrators may still override normal approval restrictions. - Azure Pipelines: Configure Approvals and Checks on the Environment or service connection outside YAML. Add branch control and an exclusive lock where concurrent releases could conflict.
- GitLab or Bitbucket-hosted code: Also protect the production environment in the source host. GitLab protected environments and deployment approvals can depend on plan; Bitbucket Cloud supports manual deployment steps and environment permissions.
Security checklist
- Use a dedicated Anypoint Connected App or supported deployment identity with the minimum environment and deployment permissions; avoid personal accounts and broad administrator access.
- Use separate credentials per environment, rotate them, and expose production credentials only to the approved production job.
- Never provide deployment secrets to pull-request or fork builds. Use isolated, short-lived hosted runners for untrusted contributions; keep self-hosted runners away from untrusted code.
- Pin the Mule Maven Plugin, Maven Wrapper, Java version, dependencies, and third-party pipeline actions or tasks. Review dependency and secret scans before promotion.
- Publish the artifact digest and source commit with the release record. Do not rebuild between staging and production; fail if the artifact or digest does not match.
- Keep deployment profiles free of credentials. Redact logs, restrict Maven settings files, and ensure temporary credential files are removed after each job.
- Define health checks, alert thresholds, and a tested rollback path before production rollout. Retain the last known-good artifact and its deployment metadata.