Cloudhub Deployment Using AuthToken In Mulesoft

 

In last tutorial we have demonstrated 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

In this tutorial we will demonstrate how we can deploy mulesoft application on cloudhub using authToken

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>
			<authToken>dfdgfgfhfhg</ authToken >
				<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-sample2-authtoken</applicationName>
						<environment>Sandbox</environment>
						<workerType>MICRO</workerType>
						<authToken>777e7e79-4a5f-47ab-a618-1901327cb926</authToken>
						<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 and update the pom.xml with authtoken

To update the pom we will generate the authToken using connected app client_id,client_credentials and grantType

 

Cloudhub Deployment Using AuthToken In Mulesoft

 

Cloudhub Deployment Using AuthToken In Mulesoft

 

Deploy the application using mvn deploy -DmuleDeploy

 

Cloudhub Deployment Using AuthToken In Mulesoft

 

Application deployed on cloudhub

Cloudhub Deployment Using AuthToken In Mulesoft

 

  
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
Inline Feedbacks
View all comments