Loading

How to define encrypted passwords in the Mule Maven Plugin

Veröffentlichungsdatum: Aug 1, 2025
Aufgabe

GOAL

It is possible to use the mule-maven-plugin to deploy projects to ARM and Cloudhub. To be able to do that, you need to configure Anypoint Platform credentials in the pom. The most basic configuration is to have them in plain text as shown below:
<plugin>
    <groupId>org.mule.tools.maven</groupId>
    <artifactId>mule-maven-plugin</artifactId>
    <version>${mule-maven-plugin.version}</version>
    <configuration>
        <deploymentType>arm</deploymentType>
        <username>myUser</username>
        <password>myPassword</password>
        <applicationName>appname</applicationName>
        <businessGroup>${deploy.businessGroup}</businessGroup>
        <environment>${deploy.environment}</environment>
        <target>${deploy.target}</target>
        <targetType>${deploy.targetType}</targetType>
        <redeploy>true</redeploy>
    </configuration>
    <executions>
        <execution>
            <id>deploy</id>
            <phase>deploy</phase>
            <goals>
                <goal>deploy</goal>
            </goals>
        </execution>
    </executions>
</plugin>
Some installations do not allow to have the password in plain text.
Schritte
Maven provides a standard way to encrypt server credentials as explained in here: https://maven.apache.org/guides/mini/guide-encryption.html
1. Follow the steps to create a master password from the link above.
2. Encrypt your password by running the command:
mvn --encrypt-password myPassword
That command will print the encrypted password.
3. Create a new server definition in your settings.xml file using the password generated in the previous step:
<settings>
...
  <servers>
...
    <server>
      <id>anypointPlatform</id>
      <username>myUser</username>
      <password>ENCRYPTED_PASSWORD</password>
    </server>
...
  </servers>
...
</settings>
4. Remove the username and password from the plugin definition and add the server name:
<plugin>
    <groupId>org.mule.tools.maven</groupId>
    <artifactId>mule-maven-plugin</artifactId>
    <version>${mule-maven-plugin.version}</version>
    <configuration>
        <deploymentType>arm</deploymentType>
        <server>anypointPlatform</server>
        <applicationName>appname</applicationName>
        <businessGroup>${deploy.businessGroup}</businessGroup>
        <environment>${deploy.environment}</environment>
        <target>${deploy.target}</target>
        <targetType>${deploy.targetType}</targetType>
        <redeploy>true</redeploy>
    </configuration>
    <executions>
        <execution>
            <id>deploy</id>
            <phase>deploy</phase>
            <goals>
                <goal>deploy</goal>
            </goals>
        </execution>
    </executions>
</plugin>
Nummer des Knowledge-Artikels

001114741

 
Laden
Salesforce Help | Article