Implementing CI/CD in mule using Jenkins
Continuous Integration (CI) is a development practice that requires developers to integrate code into a shared repository several times a day. Continuous Delivery (CD) is the ability to get changes of all types including new features, configuration changes, bug fixes, and experiments into production. Jenkin is a highly used automation tool to implement the CI/CD.
Let’s see how we setup Mulesoft CI-CD.
Prerequisite:
- JDK >=1.8
- Maven 3.x(https://maven.apache.org/download.cgi)
- Jenkins or any other continuous integration tool(https://www.youtube.com/watch?v=ksL5RNO3dpM)
- GitHub or any other SCM tool for source code management
- Anypoint Studio
- Mulesoft Anypoint CloudHub
Make sure the above settings are done properly on your machine. Once done, navigate to the pom.xml file of your project.
Add the plugin in pom.xml with cloudhubDeployment configuration
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-maven-plugin</artifactId>
<version>3.3.5</version>
<extensions>true</extensions>
<configuration>
<cloudHubDeployment>
<uri>https://anypoint.mulesoft.com</uri>
<muleVersion>4.2.2</muleVersion>
<username>dextara</username>
<password>*******</password>
<applicationName>mulesoft-cicd-sample1</applicationName>
<environment>Sandbox</environment>
<workerType>MICRO</workerType>
<objectStoreV2>true</objectStoreV2>
</cloudHubDeployment>
</configuration>
</plugin>
After adding necessary dependencies, finally, the Pom.xml file is like below.
<?xml version="1.0" encoding="UTF-8"?>
<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.3.5</mule.maven.plugin.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-maven-plugin</artifactId>
<version>3.3.5</version>
<extensions>true</extensions>
<configuration>
<cloudHubDeployment>
<uri>https://anypoint.mulesoft.com</uri>
<muleVersion>4.2.2</muleVersion>
<username>dextara</username>
<password>**********</password>
<applicationName>mulesoft-cicd-sample1</applicationName>
<environment>Sandbox</environment>
<workerType>MICRO</workerType>
<objectStoreV2>true</objectStoreV2>
</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>
<dependency>
<groupId>org.mule.connectors</groupId>
<artifactId>mule-sockets-connector</artifactId>
<version>1.1.5</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>
Once we are done with the above step, create a pipeline in Jenkins(assuming associates are aware of jenkins pipeline).
Run the pipeline. Once if the project is build successfully, Project will be deployed successfully on cloud hub.
Top site ,.. amazaing post ! Just keep the work on !
Thanks jerman!