Devops

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.

Pipeline

Let’s see how we setup Mulesoft CI-CD.

Prerequisite:

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.

vasu34k

Share
Published by
vasu34k
Tags: #mulesoft4

Recent Posts

Generative AI

Generative AI is a type of AI (such as ChatGPT) that can generate new forms…

5 months ago

Pair Programming

Pair programming is a software development technique in which two programmers work together at one…

5 months ago

AWS CodeWhisperer

Amazon recently released Amazon CodeWhisperer to the public. It is an AWS real-time AI code generator…

6 months ago

Multi-hop architecture Azure

Multi-hop architecture is a design approach for organizing data in the Delta warehouse. Multi-hop architectures…

9 months ago

MuleSoft Accelerators

MuleSoft Accelerators are predefined Mule applications, API specifications, and documentation that help to speed up the implementation life…

10 months ago

Introduction to OpenAPI

OpenAPI Specification also known as Swagger Specification is an API description format for REST APIs.…

1 year ago