Contact Us 1-800-596-4880

Deploying Apps with the Mule Maven Plugin

Mule Maven plugin versions 3.0.0, 3.1.0, 3.1.1, 3.1.2, 3.1.3, 3.1.4, 3.1.5, 3.1.6, 3.1.7, and 3.8.3 are deprecated.

Where possible, we changed noninclusive terms to align with our company value of Equality. We maintained certain terms to avoid any effect on customer implementations.

In addition to using Anypoint Runtime Manager, to deploy applications to CloudHub 2.0, you can also deploy applications by using the Mule Maven plugin. To do so, you must meet certain prerequisites, and configure your CloudHub 2.0 deployment strategy in your project’s pom.xml file.

Prerequisites

  • Ensure that the Mule Maven Plugin is added to your project

  • The application is already published in Exchange

  • The Mule Maven Facade API (v3) is added as a repository in the distribution management section of your project’s POM file. For example:

      <distributionManagement>
        <repository>
          <id>Repository</id>
          <name>Corporate Repository</name>
          <url>https://maven.anypoint.mulesoft.com/api/v3/organizations/ORGANIZATION_ID/maven</url>
          <layout>default</layout>
        </repository>
      </distributionManagement>

    See The Mule Maven Facade API documentation for more information.

Configure the CloudHub 2.0 Deployment Strategy

Inside the plugin element, add a configuration for your CloudHub 2.0 deployment, replacing the following placeholder values with your CloudHub 2.0 information:

<plugin>
  <groupId>org.mule.tools.maven</groupId>
  <artifactId>mule-maven-plugin</artifactId>
  <version>3.7.1</version>
  <extensions>true</extensions>
  <configuration>
    <cloudhub2Deployment>
      <uri>https://anypoint.mulesoft.com</uri>
      <provider>MC</provider>
      <environment>${environment}</environment>
      <target>${targetName}</target>
      <muleVersion>${muleVersion}</muleVersion>
      <username>${user}</username>
      <password>${pass}</password>
      <applicationName>${appName}</applicationName>
      <replicas>1</replicas>
      <vCores>1</vCores>
      <deploymentSettings>
        <http>
          <inbound>
            <publicUrl>${publicURL}</publicUrl>
            <forwardSslSession>true</forwardSslSession>
            <lastMileSecurity>true</lastMileSecurity>
          </inbound>
        </http>
      </deploymentSettings>
    </cloudhub2Deployment>
  </configuration>
</plugin>

Deploy to CloudHub 2.0

From the command line in your project’s folder, package the application and execute the deploy goal:

mvn clean deploy -DmuleDeploy

Redeploy to CloudHub 2.0

To redeploy the application, run the same command as you did to deploy.
CloudHub 2.0 rewrites the application you had deployed.

Authentication Methods

When you deploy applications using Mule Maven plugin, you can use different methods to provide your credentials to authenticate against the deployment platform. Depending on the authentication method you use, the parameters to set in the deployment configuration differ:

Authentication Method Description Configuration Parameters

Username and password

Use a CloudHub 2.0 username and password to authenticate.

  • username

  • password

Server

Use credentials stored in a Maven server, configured inside the Maven settings.xml file.

  • server

Authorization Token

Use an authorization token to access the platform.
See Identity Management for a list of supported single sign-on (SSO) types.

  • authToken

Connected Apps

Use a Connected App to perform the authentication programmatically by communicating with Anypoint Platform.
Note that the Connected App credentials must have the Design Center Developer access scope.
See Connected Apps for Developers for instructions about creating Connected Apps.

  • connectedAppClientId

  • connectedAppClientSecret

  • connectedAppGrantType

For a detailed description of the configuration parameters, see the CloudHub 2.0 Deployment Parameters Reference.

CloudHub 2.0 Deployment Parameters Reference

Parameter Description Required

cloudhub2Deployment

Top-Level Element

Yes

uri

Your Anypoint Platform URI.
If not set, defaults to https://anypoint.mulesoft.com.

No

muleVersion

The Mule runtime engine version to run in your CloudHub 2.0 instance.
Ensure that this value is equal to or higher than the earliest required Mule version of your application. By default, the latest available Mule version is selected.
Example values: 4.6.0 selects the last build where it defaults to Edge channel and Java 8. If you want to select a different LTS or Edge selection or Java version, specify the full Mule version name as in 4.6.0:1e-java17.
When using Mule Maven plugin versions 3.8.0 and 4.0.0 for deployments, the muleVersion property doesn’t allow you to specify releaseChannel and javaVersion. To specify these properties, upgrade the plugin to version 4.1.1 or later.
Because Mule runtime 4.4 Standard Support ends in October 2024, new Mule apps can be deployed on either Mule 4.6 LTS or Mule 4.8 Edge. As LTS channel is not supported for customers using a Mule Maven plugin version 4.1.0 or earlier, upgrade the plugin to version 4.1.1 or later.

No

releaseChannel

Set the name of the release channel used to select the Mule image. Supported values are NONE, EDGE, and LTS. By default, the value is set to EDGE. If the selected release channel doesn’t exist, an error occurs.

No

javaVersion

Set the Java version used in the deploy. Supported values are 8 and 17. By default, the value is set to 8. If the selected Java version doesn’t exist, an error occurs.

No

username

Your Anypoint Platform username

Only when using Anypoint Platform credentials to login.

password

Your Anypoint Platform password

Only when using Anypoint Platform credentials to login.

applicationName

The application name displayed in Runtime Manager after the app deploys.

Yes

scopeLoggingConfigurations

scopeLoggingConfiguration

scope

The package of the logging library to use.

logLevel

The log level. Accepted values: NONE, ERROR, WARN, INFO, DEBUG, TRACE.

Configuration example:

<scopeLoggingConfigurations>
  <scopeLoggingConfiguration>
    <scope>com.pkg.warning</scope>
    <logLevel>WARN</logLevel>
  </scopeLoggingConfiguration>
  <scopeLoggingConfiguration>
    <scope>com.pkg.debug</scope>
    <logLevel>DEBUG</logLevel>
  </scopeLoggingConfiguration>
</scopeLoggingConfigurations>

No

target

The CloudHub 2.0 target name to deploy the app to.
Specify either a shared space or a private space available in your Deployment Target values in CloudHub 2.0. See Features of CloudHub 2.0 for a detailed description on shared and private spaces. Use a value from the list of regions.

Yes

provider

Set to MC, for CloudHub 2.0.

Yes

environment

Target Anypoint Platform environment.
This value must match an environment configured in your Anypoint Platform account, as shown here:

<environment>Sandbox</environment>

Yes

replicas

Specifies the number of replicas, or instances, of the Mule application to deploy.

Yes

vCores

The size of each replica specified in vCores. Accepted values: 0.1, 0.2, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4. See CloudHub 2.0 Replicas for a detailed description of available vCore sizes and their assigned hardware resources.

No

businessGroup

The Business group path of the deployment
Specify the full hierarchical path from the parent organization to the target Business group, for example:

<businessGroup>ParentOrg\SubOrg1\myBusinessGroup</businessGroup>

This value is omitted if businessGroupId is set. If businessGroup and businessGroupId are not set, the value defaults to the main business group of the user.

No

businessGroupId

The Business group ID of the deployment
Instead of specifying the Business group path, you can specify the Business group ID to deploy your application. If businessGroupId and businessGroup are not set, the value defaults to the main business group of the user.
The Business group ID is a mandatory parameter when you have access only to a specific Business group but not to the parent organization.
This parameter is available in plugin version 3.2.7 and later.

No

deploymentTimeout

The allowed elapsed time, in milliseconds, between the start of the deployment process and the confirmation that the artifact has been deployed

The default value is 1000000.

No

server

Maven server with Anypoint Platform credentials
This is only needed if you want to use your credentials stored in your Maven settings.xml file. This is not the Mule server name.

No

properties

Top-Level element
If you need to set properties for the Mule application you are deploying, you can use the <properties> top-level element:

<properties>
  <key>value</key>
</properties>

For example:

<properties>
  <http.port>8081</http.port>
</properties>

No

secureProperties

Top-Level element
Use the secureProperties top-level element to set properties for the Mule application and instruct CloudHub 2.0 to encrypt the values before storing them:

<secureProperties>
  <key>value</key>
</secureProperties>

For example:

<secureProperties>
  <http.port>8081</http.port>
</secureProperties>

No

skip

When set to true, skips the plugin deployment goal.
Its default value is false.

No

skipDeploymentVerification

When set to true, skips the status verification of your deployed app.
Its default value is false.

No

authToken

Specifies the authorization token to access the platform. You can use this authentication method instead of setting username and password.
See Identity Management for a list of supported single sign-on (SSO) types.

Only when using an Authorization token to login.

connectedAppClientId

Specifies the Connected App clientID value.

Only when using Connected Apps credentials to login.

connectedAppClientSecret

Specifies the Connected App secret key.

Only when using Connected Apps credentials to login.

connectedAppGrantType

Specifies the only supported connection type: client_credentials.

Only when using Connected Apps credentials to login.

deploymentSettings

Any of the parameters documented in deploymentSettings Reference.

No

integrations

services

objectStoreV2

enabled

When set to true, instructs the deployment to use Object Store v2.

Configuration example:

<integrations>
  <services>
    <objectStoreV2>
      <enabled>true</enabled>
    </objectStoreV2>
  </services>
</integrations>

No

pathRewrite

Supplies the base path expected by the HTTP listener in your application. This value must begin with /. This parameter is used only for applications that are deployed to private space.

No

deploymentSettings Parameters Reference

Parameter Description

enforceDeployingReplicasAcrossNodes

Enforces the deployment of replicas across different nodes. The default value is false.
For high availability, set this value to true.

Configuration example:

<deploymentSettings>
  <enforceDeployingReplicasAcrossNodes>false</enforceDeployingReplicasAcrossNodes>
</deploymentSettings>

updateStrategy

Accepted values Description

rolling

Maintains availability by updating replicas incrementally. Requires one additional replica’s worth of resources to succeed.
If enforceDeployingReplicasAcrossNodes is enabled, the maximum number of replicas you can configure is one less than the total number of nodes.

recreate

Terminates replicas before re-deployment. Re-deployment is quicker than rolling and doesn’t require additional resources.
If enforceDeployingReplicasAcrossNodes is enabled, the maximum number of replicas you can configure is equal to the number of nodes.

The default value is rolling.

Configuration example:

<deploymentSettings>
  <updateStrategy>recreate</updateStrategy>
</deploymentSettings>

clustered

Enables clustering across two or more replicas of the application. The default value is false.

Configuration example:

<deploymentSettings>
    <clustered>true</clustered>
</deploymentSettings>

http

inbound

publicURL

URL of the deployed application. You can add multiple comma-separated values.

lastMileSecurity

Enable Last-Mile security to forward HTTPS connections to be decrypted by this application. This requires an SSL certificate to be included in the Mule application, and also requires more CPU resources. The default value is false.

forwardSslSession

Enables SSL forwarding during a session. The default value is false.

Configuration example:

<deploymentSettings>
  <http>
    <inbound>
      <publicUrl>https://myapp.anypoint.com</publicUrl>
      <lastMileSecurity>true</lastMileSecurity>
      <forwardSslSession>true</forwardSslSession>
    </inbound>
  </http>
</deploymentSettings>

generateDefaultPublicUrl

When set to true, CloudHub 2.0 generates a public URL for the deployed application.
This parameter is used only for applications that are deployed to private space. Applications that are deployed to shared space always get a generated public URL.

Encrypt Credentials

To use encrypted credentials when deploying, you need to set up your Maven master encrypted password and your settings-security.xml file.

  1. Create a master password for your Maven configuration.

    mvn --encrypt-master-password <yourMasterPassword>

    Maven returns your master password encrypted:

    {l9vZ2uM5SdgHy+H12z4pX7LEOZn3Kbnqmt3kIquLjnQ=}
  2. Create a settings-security.xml file in your ~/.m2 repository and add your encrypted master password:

    <settingsSecurity>
      <master>{l9vZ2uM5SdgHy+H12z4pX7LEOZn3Kbnqmt3kIquLjnQ=}</master>
    </settingsSecurity>
  3. Encrypt your Anypoint platform password:

    mvn --encrypt-password <yourAnypointPlatformPassword>

    Maven returns your Anypoint platform password encrypted:

    {HTWFGH5BG9QmvJ1B=}
  4. Add your encrypted Anypoint Platform password to your settings.xml file in the <server> section:

    <settings>
     ...
      <servers>
       ...
        <server>
          <id>my.anypoint.credentials</id>
          <username>my.anypoint.username</username>
          <password>{HTWFGH5BG9QmvJ1B=}</password>
        </server>
       ...
      </servers>
     ...
    </settings>
  5. In your configuration deployment, reference the credentials injecting the server ID configured in your settings.xml file:

    <plugin>
      ...
      <configuration>
        ...
        <cloudhub2Deployment>
          ...
          <server>my.anypoint.credentials</server>
          ...
        </cloudhub2Deployment>
        ...
      </configuration>
      ...
    <plugin>
    Make sure that the username and password are not set in the deployment configuration, or they will overwrite the defined server ID.