Nav

To Deploy a Mule Application to CloudHub (Mule Maven Plugin)

Prerequesites

To successfully deploy your Mule application to CloudHub, consider the following requirements:

  • The host and port number of your HTTP Listener flow sources are properly configured.

    If you are using the HTTP Listener as sources for your flow, you need to set its host to 0.0.0.0 and its port to ${http.port}.
    CloudHub then dynamically allocates a port at deployment time.

  • All your external classes and resources are properly declared in the mule-artifact.json file of your Mule application.

    Due to Mule 4.x classloading isolation mechanism, all external classes and resources must be explicitly declared in the "exportedPackages" and "exportedResources" fields on the mule-artifact.json file before packaging and deploying the application.

    See the How to Export Resources task to learn more about working with external resources in your Mule application.

Deploying to CloudHub

  1. Make sure you added the Mule Maven Plugin to your pom.xml file.

  2. Inside the plugin you element, add a configuration for your CloudHub deployment as shown below:

    
                
             
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    
    <plugin>
      ...
        <configuration>
            <cloudHubDeployment>
                <uri>https://anypoint.mulesoft.com</uri>
                <muleVersion>${mule.version}</muleVersion>
                <username>${username}</username>
                <password>${password}</password>
                <applicationName>${cloudhub.application.name}</applicationName>
                <environment>${environment}</environment>
                <properties>
                    <key>value</key>
                </properties>
            </cloudHubDeployment>
        </configuration>
    
    </plugin>

    The example is using placeholder values. Configure each value with your own CloudHub information.

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

    
                
             
    1
    
    > mvn clean package deploy -DmuleDeploy

Redeploying to CloudHub

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

Encrypting credentials

To use encrypted credentials when deploying to CloudHub 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.

    
                   
                
    1
    2
    3
    
    <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:

    
                
             
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    
    <settings>
    ...
      <servers>
    ...
        <server>
          <id>my.anypoint.credentials</id>
          <username>my.anypoint.username</username>
          <password>{HTWFGH5BG9QmvJ1B=}</password>
        </server>
    ...
      </servers>
    ...
    </settings>
  5. In your the configuration deployment, reference the credentials id injecting the server id:


         
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<plugin>
  ...
    <configuration>
        <cloudHubDeployment>
            <uri>https://anypoint.mulesoft.com</uri>
            <muleVersion>${mule.version}</muleVersion>
            <server>my.anypoint.credentials</server>
            <applicationName>${cloudhub.application.name}</applicationName>
            <environment>${environment}</environment>
            <properties>
                <key>value</key>
            </properties>
        </cloudHubDeployment>
    </configuration>

</plugin>
Make sure that username and password are not set in the deployment configuration, as they have precedence over the defined server id.

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.

+