Cloudhub Deployment Using Connected App In Mulesoft
In previous tutorial we have deployed the application on cloudhub using Jenkins with the use of mule maven plugin and with anypoint username and password
In this tutorial we will demonstrate how can we use the connected app(see for more details) and deploy the mulesoft application on cloudhub without using the anypoint username and password
We will use the GitHub as a source repository and Jenkins as build tool to deploy the application
Add the plugin in pom.xml with cloudhubDeployment configuration
<plugin> <groupId>org.mule.tools.maven</groupId> <artifactId>mule-maven-plugin</artifactId> <version>3.4.0</version> <extensions>true</extensions> <configuration> <cloudHubDeployment> <uri>https://anypoint.mulesoft.com</uri> <muleVersion>4.3.0</muleVersion> <applicationName>mulesoft-cicd-sample1</applicationName> <environment>Sandbox</environment> <workerType>MICRO</workerType> <connectedAppClientId>0a2e2d765f894691aa7cdeecb03bb80 </connectedAppClientId> <connectedAppClientSecret>280bCD709ffF435A46Bbd0607209862 </connectedAppClientSecret> <connectedAppGrantType>client_credentials</connectedAppGrantType> <objectStoreV2>true</objectStoreV2> <region>us-east-2</region> </cloudHubDeployment> </configuration> </plugin>
POM.XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mycompany</groupId> <artifactId>mulesoft-cicd-sample1</artifactId> <version>1.0.0-SNAPSHOT</version> <packaging>mule-application</packaging> <name>mulesoft-cicd-sample1</name> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <app.runtime>4.2.2</app.runtime> <mule.maven.plugin.version>3.4.0</mule.maven.plugin.version> </properties> <build> <plugins> <plugin> <groupId>org.mule.tools.maven</groupId> <artifactId>mule-maven-plugin</artifactId> <version>3.4.0</version> <extensions>true</extensions> <configuration> <cloudHubDeployment> <uri>https://anypoint.mulesoft.com</uri> <muleVersion>4.3.0</muleVersion> <applicationName>mulesoft-cicd-sample1</applicationName> <environment>Sandbox</environment> <workerType>MICRO</workerType> <connectedAppClientId>0a2e2d765f894691aa7cd5eecb03bb80</connectedAppClientId> <connectedAppClientSecret>280bCD709ffF435CA46Bbd0607209862</connectedAppClientSecret> <connectedAppGrantType>client_credentials</connectedAppGrantType> <objectStoreV2>true</objectStoreV2> <region>us-east-2</region> </cloudHubDeployment> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.mule.connectors</groupId> <artifactId>mule-http-connector</artifactId> <version>1.5.11</version> <classifier>mule-plugin</classifier> </dependency> </dependencies> <repositories> <repository> <id>anypoint-exchange-v2</id> <name>Anypoint Exchange</name> <url>https://maven.anypoint.mulesoft.com/api/v2/maven</url> <layout>default</layout> </repository> <repository> <id>mulesoft-releases</id> <name>MuleSoft Releases Repository</name> <url>https://repository.mulesoft.org/releases/</url> <layout>default</layout> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>mulesoft-releases</id> <name>mulesoft release repository</name> <layout>default</layout> <url>https://repository.mulesoft.org/releases/</url> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> <pluginRepository> <id>mule-public</id> <url>https://repository.mulesoft.org/nexus/content/repositories/releases</url> </pluginRepository> </pluginRepositories> </project>
We will reuse the mule application created as part of previous tutorial which is already there in GitHub
We will clone the project and update the POM.xml and commit the changes to HitHub
To update the pom.xml we will copy the connected app client_id,client secret and grant type as client_credentials
Start the Jenkins Server
Commit the latest pom changes on github, a build will deploy on cloudhub
Sample application: mulesoft-cicd-sample