I’ve recently started working with Mule 4 from years of doing Mule 3 and I’ve had to figure out a number of differences in the Mule 4 POM files with few documented use cases. The biggest change has been how the Mule Maven Plugin works for deployment into the cloud. My previous posts have been about deployment, so I’ll go into a bit on the new mule-maven-plugin.

<plugin>
  <groupId>org.mule.tools.maven</groupId>
  <artifactId>mule-maven-plugin</artifactId>
  <version>${mule.maven.plugin.version}</version>
  <extensions>true</extensions>
  <configuration>
    <deploymentType>cloudhub</deploymentType>
    <cloudHubDeployment>
      <applicationName>${project.artifactId}-${mule.env}</applicationName>
      <muleVersion>${app.runtime}</muleVersion>
      <username>${anypoint.username}</username>
      <password>${anypoint.password}</password>
      <environment>${mule.env}</environment>
      <properties>
        <mule.env>${mule.env}</mule.env>
      </properties>
      <region>us-east-1</region>
      <workerType>${mule.workerType}</workerType>
      <workers>${mule.workers}</workers>
    </cloudHubDeployment>

    <sharedLibraries>
      <sharedLibrary>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
      </sharedLibrary>
    </sharedLibraries>
    <classifier>mule-application</classifier>

  </configuration>
  <executions>
    <execution>
      <id>deploy</id>
      <phase>deploy</phase>
      <goals>
        <goal>deploy</goal>
      </goals>
      <configuration>
        <classifier>mule-application</classifier>
      </configuration>
    </execution>
  </executions>
</plugin>

I’ve highlighted the fieds in the beginning of the <configuration> tag because they are the ones that are new for Mule 4.  One big advantage here is that it could be possible to deploy to Cloudhub.

I set the variables in this in a couple different places.

In a previous post I talked about where to store  config files on Jenkins easily.  I store the fields:

<username>${anypoint.username}</username> 
<password>${anypoint.password}</password>

in this config file.

In Jenkins when I run a deploy, using the job parameters I select:

<workerType>${mule.workerType}</workerType>
<workers>${mule.workers}</workers>

At the time of deployment, or I code these into the job.  It’s typical that you might want to have a different size and number of workers for different environments: dev, stage, or production.

But there’s a bug

At this time there also seems to be a bug that I haven’t correlated to any action I can control.  Every 1 out of 3 or 4 deploys I do will fail with the error “No Application File Found”.  Usually I can run it again and it will succeed.  Unfortunately this error seems to only show up on Anypoint Cloudhub logs and Jenkins seems to not know about it.  So at this time I have to monitor Anypoint deploy logs to make sure it deploys.