Implementing CI/CD in Mule Using Jenkins

Author: Kishan Jasani

Introduction

CI/CD is a method to frequently deliver apps to customers by introducing automation into the stages of app development. The main concepts attributed to CI/CD are continuous integration, continuous delivery, and continuous deployment. CI/CD is a solution to the problems integrating new code can cause for development and operations.

Specifically, CI/CD introduces ongoing automation and continuous monitoring throughout the lifecycle of apps, from integration and testing phases to delivery and deployment. Taken together, these connected practices are often referred to as a “CI/CD pipeline.” They are supported by development and operations teams working together in an agile way with a DevOps approach.

Prerequisites

Anypoint Platform setup

  • Navigate to your GitHub account https://github.com
  • Check your GitHub credentials ( username and password) and Login
  • Create a Repository and Push your code
  • Save git repository URL Where you want to implement CI/CD pipeline (https://github.com/Kishan-Jasani/bookmyholiday-ws.git)
  •  Unzip the executable jar and host the application on port 8080
  • Project level configuration
  • Open pom.xml of your mule project
  • Find <plugin> tag under <plugins> where <groupId> is equal to org.mule.tools.maven
<plugin>
    <groupId>org.mule.tools.maven</groupId>
    <artifactId>mule-maven-plugin</artifactId>
    <version>${mule.maven.plugin.version}</version>
    <extensions>true</extensions>
</plugin>
  • Add <configuration> tag inside <plugin>
<plugin>
    <groupId>org.mule.tools.maven</groupId>
    <artifactId>mule-maven-plugin</artifactId>
    <version>${mule.maven.plugin.version}</version>
    <extensions>true</extensions>
    <configuration>
        <cloudHubDeployment>
            <uri>https://anypoint.mulesoft.com</uri>
            <muleVersion>${mule.version}</muleVersion>
            <username>${anypoint.username}</username>
            <password>${anypoint.password}</password>
            <environment>${env}</environment>
            <applicationName>${appname}</applicationName>
            <businessGroup>${business}</businessGroup>
            <workerType>${vCore}</workerType>
            <workers>${workers}</workers>
            <objectStoreV2>true</objectStoreV2>
        </cloudHubDeployment>
    </configuration>
</plugin>
  • Setting up CI CD Pipeline using Jenkins
  • Navigate to http://localhost:8080/ and login with admin username and password
  • Click on Manage Jenkins     →           Manage Credentials
  • Under Stores scoped to Jenkins on the right, click on Jenkins
  • Under System, click the Global credentials (unrestricted) link to access this default domain.
  • Click Add Credentials on the left.
  • Enter your Github Username and Password and click on OK
  • Navigate to http://localhost:8080/ and click on New Item
  • Enter an item name, select Free Style Project and click on OK
  • You will be navigated to the configuration page
  • Enter Pipeline Description and GitHub Project url where you want to implement CI CD pipeline
  • Scroll down to Source Code Management and select git.
  • Add Repository URL and select credential from drop down
  • Specify branch of your repository where you want to set up your CI CD pipeline
  • Under Build Triggers, click on Poll SCM and write cron expressions as per your requirement. 

(For example, write ‘* * * * *’ ,If you want to check the update on repository every minute)

  • Under Build, Add build step ‘Invoke top-level Maven targets
  • Select Maven Version as ‘MAVEN_HOME’ and write Goals

(You Copy and Paste Goals from below)

  • Goals:-
clean deploy -DmuleDeploy -DskipTests -Dmule.version=4.3.0 -Danypoint.username=<Your Anypoint Platform Username> -Danypoint.password=<Your Anypoint Platform Password> -Denv=<Your Anypoint Platform Environmanet> -Dappname=cicd-pipeline-demo -Dbusiness=Apisero -DvCore=Micro -Dworkers=1
  • Click on Apply
  • Click on Save
  • You will be redirected to Dashboard. Build will start automatically every time you change your code in the GitHub repository.
  • Your Pipeline will start running. You can see the Console Output
  • Your Project will start deploying automatically in your Anypoint Platform
  • We are now ready with our CI CD pipeline

We use cookies on this site to enhance your user experience. For a complete overview of how we use cookies, please see our privacy policy.