Recipe To Implement the Jenkins Pipeline For MuleSoft Application

Author: – Jitendra Bafna

1.0 What is DevOps?

DevOps is a culture which promotes collaboration between Development and IT Operations Team to deploy code to production faster in an automated & repeatable way.

1.1 Benefits of DevOps

  • Releases/deployment can be done more frequently and quicker.
  • Shorter mean time to repair.
  • Cost Reduction and Reliable deployment.
  • Fault Isolation.

2.0 What is CI/CD?

Continuous Integration is development practice where developer checked in the code multiple times a day in shared repository. Each integration is verified by automated build and automated unit testing.

Continuous Deployment is ability to move the changes including Features, Bug Fixes into the production quicker.

2.1 Benefits of CI/CD

  • Quicker Releases
  • Smaller Code Changes.
  • Faster Mean Time To Resolution (MTTR).
  • Improved Test ability.
  • Customer Satisfaction.

3.0 What is Jenkins?

Jenkins is an open source Continuous Integration server capable of orchestrating a chain of actions that help to achieve the Continuous Integration process (and not only) in an automated fashion.

Jenkins is free and is entirely written in Java. Jenkins is a widely used application around the world that has around 300k installations and is growing day by day.

4.0 CI/CD Tools For Deploying MuleSoft Application

There are many tools available to achieve CI/CD pipeline. In today’s demonstration, we will walk through the list of tools and they are widely used tools for achieving DevOps for your Mulesoft services/applications.

Tool Description
Github GitHub is a Git repository hosting service and provides a Web-based graphical interface. It also provides access control and several collaboration features, such as a wikis and basic task management tools for every project
Git Git is the most commonly used version control system today and is quickly becoming the standard for version control. Git is a distributed version control system, meaning your local copy of code is a complete version control repository. 
MUnit MUnit is a Mule application testing framework which allows you to build automated tests for your Mule integrations and API’s. MUnit is very well integrated with Anypoint Studio.
Nexus Nexus is a repository manager. It allows you to proxy, collect, and manage your dependencies so that you are not constantly juggling a collection of JARs
SonarQube SonarQube (formerly Sonar) is an open-source platform developed by SonarSource for continuous inspection of code quality to perform automatic reviews with static analysis of code to detect bugs, code smells, and security vulnerabilities on 20+ programming languages.

4.1 MUnit

MUnit is a Mule application testing framework which allows you to build automated tests for your Mule integrations and API’s. MUnit is very well integrated with Anypoint Studio.

4.1.1 MUnit Matchers

MUnit matchers are a set of DataWeave functions to define assertion conditions for any value in an expression. When defining matchers, include the prefix MunitTools:: in the expression.

Matchers are grouped according to the type of conditions you want to validate.

Type Of Matchers

  • Core Matchers
  • String Matchers
  • Comparable Matchers
  • Iterable and Map Matchers

For more details on MUnit Matchers,Click here.

5.0 Apache JMeter

Apache JMeter is open-source software that is popular for performance testing. This tool is designed to load test functional behavior and measure performance.

It is very easy to integrate Apache JMeter With Jenkins for performing the load testing and generating the reports.

For generating the performance trend reports and plot the response time, throughput charts, two plugins needs to install on Jenkins

  • Performance Plugin
  • Plot Plugin

6.0 Postman And Newman CLI

Postman is currently one of the most popular tools used in API testing. API stands for Application Programming Interface which allows software applications to communicate with each other via API calls.

A Postman Collection lets you group individual requests together. You can organize these requests into folders.

Postman Tests are JavaScript codes added to requests that help you verify results such as successful or failed status, comparison of expected results, etc. It usually starts with pm.test. It can be compared to asserts, verify commands available in other tools.

Newman is a command line Collection Runner for Postman. It allows you to run and test a Postman Collection directly from the command line. It is built with extensibility in mind so that you can easily integrate it with your continuous integration servers and build systems. 

It is capable of generating Command Line as well as HTML reports.

Some Useful Newman Commands

Install Newman NPM: – npm install -g newman

Run Newman Tests: – newman run Collection.postman_collection.json

Install HTML Extra: – npm install -g newman-reporter-htmlextra

Run Newman HTML Report: – newman run postman_collection.json -r htmlextra –reporter-htmlextra-export “path”

6.1 Newman Command Line Report

6.2 Newman HTML Report

7.0 MuleSoft Deployment Options

Mulesoft provides various options for deploying your application.

  • Standalone (On-premises)
  • Cluster
  • CloudHub
  • Anypoint Runtime Fabric
  • Private Cloud

7.1 Mule Maven Plugin

Mule Maven Plugin provided functionality of deploying and undeploying application to on-premise, cloudhub, cluster or anypoint runtime fabric. You need to add Mule Maven Plugin into your POM.xml of your application.

<plugin>

   <groupId>org.mule.tools.maven</groupId>

   <artifactId>mule-maven-plugin</artifactId>

   <version>3.3.5</version>

</plugin>

7.1.1 Deploy Application

mvn clean package deploy -DmuleDeploy

7.1.2 Undeploy Application

mvn mule:undeploy

7.2 Deploying Mule Application to Cloudhub using Mule Maven Plugin

Mule Maven Plugin has the capability of deploying applications to Anypoint CloudHub. We need to understand some of Mule Maven plugin parameters required for deploying application to CloudHub.

Parameter Description
uri Your Anypoint Platform URI.If not set, by default this value is set to https://anypoint.mulesoft.com
muleVersion The Mule runtime engine version that will run in your CloudHub instance.
applicationName The name of your application in CloudHub.
username Your Cloudhub username.
password Your Cloudhub password.
server Maven server with Anypoint Platform credentials. 
workers The number of workers.By default, it is set to 1
workerType Size of each worker.The default value is MICRO.
environment The CloudHub environment to which you want to deploy.
businessGroup Business Group of Deployment.
properties If you need to set properties for the Mule application you are deploying, you can use the <properties> top-level element:<properties><key>value</key></properties>For example:<properties><http.port>8081</http.port></properties>
region Region of workers cloud.The default value is us-east-1.

7.3 Deploying Mule Application to On-Premise using Mule Maven Plugin

Mule Maven Plugin has the capability of deploying applications to on-premise mulesoft runtime. We need to understand some of Mule Maven plugin parameters required for deploying application to mulesoft runtime.

Parameter Description
muleVersion The Mule version running in your local machine instance.If this value does not match the Mule version running in your deployment target, the plugin raises an exception.
muleHome The location of the Mule instance in your local machine.

8.0 YouTube Videos References

Topic Link
Deploying Mulesoft Application to Cloudhub using Mule Maven Plugin https://youtu.be/ngnVZjJFGJI
Deploying Mulesoft application to Cloudhub using Jenkins and Maven https://youtu.be/u7vgl-dDXi4
Configuring Jenkins CI/CD Pipeline For Mulesoft Applications | Mulesoft | GIT | GitHub – Part I https://youtu.be/22rd4Gz5SBU
Configuring Jenkins CI/CD Pipeline For Mulesoft Applications | Mulesoft | CloudHub – Part II https://youtu.be/GIln9FOnjho
Configuring Jenkins CI/CD Pipeline For Mulesoft Applications | Postman | Newman – Part III https://youtu.be/5PntSRhOXzQ
Configuring Jenkins CI/CD Pipeline For Mulesoft Applications | Muelsoft | Jenkinsfile – Part IV https://youtu.be/ca1bEIz_4sA
Configuring Jenkins CI/CD Pipeline For Mulesoft Applications | Mulesoft | Jenkinsfile – Part V https://youtu.be/Eh_L9bIEP9s
Create Postman Test Collection Suite for Mulesoft API | Mulesoft | Postman https://youtu.be/Zi5l0-NH0cQ
Performance or Load Testing for Mulesoft API Using Apache JMeter | Mulesoft | Apache JMeter https://youtu.be/m_ISYTuwpBc

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.