Deploying a Mule Application on RTF using Jenkins CI/CD Pipeline and GitLab

Rohit Singh
Another Integration Blog
4 min readOct 30, 2023

This article will explain how to deploy a Mule Application on Runtime Fabric by Jenkins CI/CD Pipeline using GitLab. I will begin by explaining key terminology.

CI/CD

CI is short for Continuous Integration, a software development practice in which all developers merge code changes in a central repository multiple times.

CD stands for Continuous Delivery, which automates the entire software release process.

RTF

Anypoint Runtime Fabric is a container service that allows you to run Mule applications, composite APIs, and API gateways across any environment with centralized management via the Anypoint Platform.

Prerequisites for RTF CI/CD Pipeline With MuleSoft Using Jenkins

Anypoint Studio will be the integrated development environment (IDE) used to develop your application. An active Anypoint Platform account will be needed to access the cloud-based control plane. Maven and Git will need to have already been installed on your local system. Anypoint RTF should already be active and setup on your Anypoint Platform account. Jenkins will be used as the continuous integration tool, and the following Jenkins plugins should already be active and configured: Config File Provider Plugin (to pass the Settings.xml file) and GitLab API Plugin.

Note: Confidential fields are masked in the following demonstration.

Steps:

Step 1. Create a project in Anypoint Studio, which we will eventually deploy on RTF. In this blog, I will walk you through a simple example consisting of an HTTP Listener and a Transform Message component.

The triggering flow

Step 2. Configure your project’s pom.xml file to enable the deployment of your project on RTF via Maven. This uses the Mule-Maven-plugin which will have already been added to your project’s pom.xml file at the time of project creation. In case it is missing, add the dependency and use the following configuration for Runtime Fabric deployment.

Example deployment settings for Anypoint RTF in pom.xml file

Step 3. Before we can deploy our application to RTF, the application must first be deployed to your organization’s Anypoint Exchange in order to avoid a Maven dependency not found error. To do this, add the code below to the pom.xml file so that it will first publish the application to Anypoint Exchange.

<distributionManagement>
<repository>
<id>
anypoint-exchange</id>
<name>
Exchange Repository</name>
<url>
https://maven.anypoint.mulesoft.com/api/v1/organizations/your-org-id/maven</url>
<layout>
default</layout>
</repository>
</distributionManagement>

Step 4. These variables can be defined at runtime in the Jenkins file script, or they can be directly assigned in the pom.xml file. For further reading on these properties or any additional flags, you can consult the official documentation for configuring the Anypoint RTF deployment strategy.

Step 5. Add the Anypoint Platform credentials to the settings.xml file. We can check this settings.xml file into Jenkins. Note: the file ID for the settings.xml file will be needed later in the process.

<server>
<id>
deploymentRepo</id>
<username>
repouser</username>
<password>
repopwd</password>
</server>

Step 6. Create a script in the Jenkinsfile for pipeline execution.

Below is sample code for such a Jenkins pipeline script:

Sample Jenkins pipeline script

Step 7. Import your code into a GitLab repository along with the Jenkinsfile.

A GitLab repository with imported files

Step 8. Configure the Jenkins pipeline.

a) Create a pipeline job

Creating a pipeline job in Jenkins

b) Under the Pipeline tag, add the following configurations:

  • Definition: pipeline script from the SCM
  • Source Code Management (SCM): Specify Git.
  • Repository URL: Specify the URL of the repository from which the code should be picked up from.
  • Credentials: Store the GitLab credentials in Jenkins securely.
  • Branch: Give the branch name from where you want to pick up Build (e.g., main or feature).
  • Script Path: Give the name as Jenkinsfile, which is the name of the file containing the Jenkins pipeline script created earlier.

Step 9. Click on the Build button and your pipeline will start running. You will see successful deployment in RTF.

Step 10. If you want to automatically trigger the pipeline, you will need to set up Webhooks or Integrations under the Settings tab in GitLab.

GitLab Settings submenu

Click on ‘Integrations,Add an Integration’, and ‘Jenkins’. Next, fill in following fields:

  • Enable integration: Tick this option.
  • Trigger: Tick Push (to trigger events for pushes to the repository). You can add other trigger event types (e.g. Merge request, Tag push) according to your requirements.
  • Add Jenkins server URL.
  • Project name: Specify the name of the Jenkins project. This project name may be extracted from the end of the Jenkins server URL.
  • The username for the Jenkins server.
  • The password for the Jenkins server.

Summary:

In this blog, the process of deployment for RTF using the CI/CD pipeline. You should now understand how to configure Jenkins and GitLab for successful deployment in the RTF.

--

--