Deploy Applications to Runtime Fabric Using 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, and 3.1.7 are deprecated.

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

If you want to deploy applications to Runtime Fabric using a different method, see:

Prerequisites

Configure the Runtime Fabric Deployment Strategy

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

<plugin>
  <groupId>org.mule.tools.maven</groupId>
  <artifactId>mule-maven-plugin</artifactId>
  <version>3.4.2</version>
  <extensions>true</extensions>
  <configuration>
    <runtimeFabricDeployment>
      <uri>https://anypoint.mulesoft.com</uri>
      <muleVersion>4.3.0</muleVersion>
      <username>user</username>
      <password>pass</password>
      <applicationName>newapp</applicationName>
      <target>rtf</target>
      <environment>Sandbox</environment>
      <provider>MC</provider>
      <replicas>1</replicas>
      <properties>
        <key>value</key>
      </properties>
      <deploymentSettings>
        <enforceDeployingReplicasAcrossNodes>false</enforceDeployingReplicasAcrossNodes>
        <updateStrategy>recreate</updateStrategy>
        <clustered>false</clustered>
        <forwardSslSession>false</forwardSslSession>
        <lastMileSecurity>false</lastMileSecurity>
        <resources>
          <cpu>
            <reserved>20m</reserved>
            <limit>1500m</limit>
          </cpu>
          <memory>
            <reserved>700Mi</reserved>
          </memory>
        </resources>
        <http>
          <inbound>
            <publicUrl>url</publicUrl>
          </inbound>
        </http>
      </deploymentSettings>
    </runtimeFabricDeployment>
  </configuration>
</plugin>

Deploy to Runtime Fabric

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

mvn clean package deploy -DmuleDeploy

Redeploy to Runtime Fabric

To redeploy the application, run the same command as you did to deploy.
Runtime Fabric 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 Runtime Fabric 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 Runtime Fabric Deployment Parameters Reference.

Runtime Fabric Deployment Parameters Reference

Parameter Description Required

runtimeFabricDeployment

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 Runtime Fabric instance.
Ensure that this value is equal to or higher than the earliest required Mule version of your application.
Example values: 4.3.0, 4.2.2-hf4

Yes

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

target

The Runtime Fabric target name where to deploy the app.

Yes

provider

Set to MC, for Runtime Fabric.

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

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>

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.
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

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

deploymentSettings Parameters Reference

Parameter Description

enforceDeployingReplicasAcrossNodes

Enforces the deployment of replicas across different nodes. The default value is false.

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>

forwardSslSession

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

Configuration example:

<deploymentSettings>
  <forwardSslSession>true</forwardSslSession>
</deploymentSettings>

clustered

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

Configuration example:

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

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.
Configuration example:

<deploymentSettings>
    <lastMileSecurity>true</lastMileSecurity>
</deploymentSettings>

resources

cpu

reserved

Specifies the number of cores to allocate for each application replica. The default value is 0.5 vCores.

limit

Specifies the number of max cores to allocate for each replica of the application.
If a reserved configuration is present, ensure that this value is equal or higher.

memory

reserved

Specifies the amount of memory to allocate for each application replica. The default value is 700 MB.

Configuration example:

<deploymentSettings>
  <resources>
    <cpu>
      <reserved>20m</reserved>
      <limit>1500m</limit>
    </cpu>
    <memory>
      <reserved>700Mi</reserved>
    </memory>
  </resources>
</deploymentSettings>

http

inbound

publicURL

URL of the deployed application.

Configuration example:

<deploymentSettings>
  <http>
    <inbound>
      <publicUrl>myapp.anypoint.com</publicUrl>
    </inbound>
  </http>
</deploymentSettings>

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>
        ...
        <runtimeFabricDeployment>
          ...
          <server>my.anypoint.credentials</server>
          ...
        </runtimeFabricDeployment>
        ...
      </configuration>
      ...
    <plugin>
    Make sure that the username and password are not set in the deployment configuration, or they will overwrite the defined server ID.

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub