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

Cloudhub Deployment Using Connected App In Mulesoft

 

Commit the latest pom changes on github, a build will deploy on cloudhub

Cloudhub Deployment Using Connected App In Mulesoft

 

Cloudhub Deployment Using Connected App In Mulesoft

 

Sample application: mulesoft-cicd-sample

  
Thank you for taking out time to read the above post. Hope you found it useful. In case of any questions, feel free to comment below. Also, if you are keen on knowing about a specific topic, happy to explore your recommendations as well.
 
For any latest updates or posts on our website, you can follow us on LinkedIn. Look forward to connecting with you there.


Share this:
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments