Mule Application Builds and Deployment can be fully managed using Maven. In the development phase, Anypoint Studio makes it easy to manage your application dependencies using Maven.
For Deployment tasks, Mule provides a Maven plugin that can help to automate the application deployment to different target runtime environments such as Standalone, CloudHub, ARM, Cluster and more from Mulesoft Certification

There are different ways to Install and Run Mule Runtime –
- Local Standalone Server: Mule Runtime installation on your local server and Mule runs as a single server instance.
- Local Cluster: Similar individual instance set up on local, except they are part of a cluster to interact with each other.
- CloudHub: Integration platform as a service (iPaas) provided by MuleSoft, where you Mule runs in the cloud.
- Pivotal Cloud Foundry: Mule Runtime deployed on Pivotal Cloud Foundry.
Deployments to all these environments can be managed through Manual Copy (For Local), Anypoint Runtime Manager, or Maven Deploy Plugin.
In this post, we will see how we can leverage Mule Maven plugin to perform deployments. We will do a deployment to Standalone Mule Instance as well as to CloudHub Instance. In the end, we will also automate our deployment using Jenkins Pipeline. Learn more info from Mule Training
Version used:
- Mule Runtime 3.9.0
- Jenkins 2.11.0
- Mule Maven Plugin 2.3.3
Mule Maven Plugin
The mule-maven-plugin is a Maven Plugin provided as a part of Mule Framework. It allows us to run integration tests for Mule Application, and also to deploy the application to various environments.
Configuration
This plugin is available in the Mulesoft public repository, so you will need to add below repository to your settings.xml –
<pluginRepositories>
<pluginRepository>
<id>mule-public</id>
<url>https://repository.mulesoft.org/nexus/content/repositories/releases</url>
</pluginRepository>
</pluginRepositories>
Once you have added the repository, you can include the plugin in your pom.xml as –
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-maven-plugin</artifactId>
<version>2.3.3</version>
</plugin>
At this point, you are ready to add configuration for your target server/environment.
Deployment Profiles:
We may have different environments available for deploying our application. It is even possible that, you have a mix of Local Standalone Server and CloudHub approach.
So, Instead of configuring our pom.xml for a single environment, we will use a Maven parent POM approach. We will define a Maven Parent POM and add a Maven Profile for each of our target environments.
Below profile will help us deploying to local mule server –
<profile>
<id>standalone</id>
<build>
<plugins>
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-maven-plugin</artifactId>
<configuration>
<standaloneDeployment>
<muleVersion>${mule.version}</muleVersion>
<muleHome>${mule.home}</muleHome>
<applicationName>${artifactId}</applicationName>
</standaloneDeployment>
</configuration>
<executions>
<execution>
<id>deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
| Target Mule Version if Mule should be installed as a part of deployment. |
| This should be a path to our locally installed mule server, such as /opt/mule. Mule Version and Mule Home are exclusive to each other. |
| Application name to be used when deploying to Mule instance. |
Below profile will help for CloudHub Deployment –
<profile>
<id>cloudhub</id>
<build>
<plugins>
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-maven-plugin</artifactId>
<configuration>
<cloudHubDeployment>
<muleVersion>${mule.version}</muleVersion>
<username>${anypoint.username}</username>
<password>${anypoint.password}</password>
<applicationName>${artifactId}-${maven.build.timestamp}</applicationName>
<environment>${cloundhub.env}</environment>
<businessGroup>${anypoint.businessGroup}</businessGroup>
<region>${cloudhub.region}</region>
<uri>${anypoint.uri}</uri>
<workerType>${cloudhub.workerType}</workerType>
<workers>${cloudhub.workers}</workers>
</cloudHubDeployment>
</configuration>
<executions>
<execution>
<id>deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Target Mule Runtime Version where Application should be deployed.Anypoint Platform Username with appropriate access to target environment.Anypoint Platform User’s password.Application Name for CloudHub.
To generate unique name for demo application, timestamp is appended to the name.Target Environment as configured on ARM.If you are running ARM on private instance then specify url here. For more additional info Mulesoft Training
Eg. anypoint.example.com Worker Type to be one of: Micro (0.1 vCores), Small (0.2 vCores), Medium (1 vCores), Large (2 vCores), xLarge (4 vCores).
Jenkins Pipeline:
As per Jenkins website –
Jenkins Pipeline (or simply “Pipeline”) is a suite of plugins which supports implementing and integrating continuous delivery pipelines into Jenkins.
In this post, I will not go into much detail about Pipeline and presume that you are aware of it. This Jenkins Document may give you a good overview of what Pipeline is.
Jenkins Setup
CloudHub and ARM deployment would need to access Anypoint Platform. Let’s add Anypoint Credentials in Jenkins Credential. We will use these credentials in our Pipeline to avoid hardcoding and password exposure.
If you do not specify anything in ID attribute, Jenkins will assign and auto generated ID. We will need this ID value for credential lookup in Pipeline.
Simple Pipeline
Now, we have all that we need for adding a Jenkins Pipeline to our Mule Application. For this, we will need to create a file named Jenkinsfile in the root of our application.
Here is the content of our Jenkinsfile –
pipeline {
agent any
stages {
stage('Unit Test') {
steps {
sh 'mvn clean test'
}
}
stage('Deploy Standalone') {
steps {
sh 'mvn deploy -P standalone'
}
}
stage('Deploy ARM') {
environment {
ANYPOINT_CREDENTIALS = credentials('anypoint.credentials')
}
steps {
sh 'mvn deploy -P arm -Darm.target.name=local-3.9.0-ee -Danypoint.username=${ANYPOINT_CREDENTIALS_USR} -Danypoint.password=${ANYPOINT_CREDENTIALS_PSW}'
}
}
stage('Deploy CloudHub') {
environment {
ANYPOINT_CREDENTIALS = credentials('anypoint.credentials')
}
steps {
sh 'mvn deploy -P cloudhub -Dmule.version=3.9.0 -Danypoint.username=${ANYPOINT_CREDENTIALS_USR} -Danypoint.password=${ANYPOINT_CREDENTIALS_PSW}'
}
}
}
}
Stage to Run Unit tests on our Mule Application.Deploy our Mule Application to Standalone server. As we are not passing in mule.home parameter value, this step will actually download the Mule server from Mule Maven Repository and install it in Jenkins workspace.
If you want to deploy to already installed instance, then you may add a parameter -Dmule.home=/opt/mule in maven command.Deploy to a Mule Server Managed via Anypoint Runtime Manager.
Credential Lookup: We need Anypoint Platforms credentials for this step. We will use jenkins credentials() function to lookup our credentials using ID value.
This function then automatically sets two environment variables named {ourvariable}_USR and {ourvariable}_PSW.Use Credential variables to set Anypoint Username and Password while calling our arm profile.
Deploy to CloudHub using cloudhub profile. Credentials setup is same as deploying to ARM.For CloudHub deployments, mule.version must be same as it appears on CloudHub available Runtime version names.
Mule Runtime can be installed on many platforms and Mule Maven plugin does simplify the deployment process.
We can also do integration tests using this plugin. We used Mule Maven plugin and Jenkins Pipeline to automate our mule deployment to Anypoint Runtime Manager as well as CloudHub environment.
To get in-depth knowledge, enroll for a live free demo on Mulesoft Online Training