Deploying MuleSoft Using Azure DevOps
Deploying MuleSoft Using Azure DevOps
This article introduces Azure DevOps and provides a step-by-step guide on how to deploy MuleSoft with Azure DevOps.
Join the DZone community and get the full member experience.Join For Free
Azure DevOps Server is a Microsoft product that provides version control, reporting, requirements management, project management, automated builds, lab management, testing and release management capabilities. In short, it covers the entire application lifecycle and enables DevOps capabilities.
Here we are going to see how to implement CI/CD pipeline for MuleSoft application using Azure DevOps.
Step 1: Make sure you have added the Mule-Maven plugin in your pom.xml.
<cloudHubDeployment> tag of the Mule Maven plugin defines the attributes of your deployable.
So let's see what each of these properties tells us about the deployment onto CloudHub.
- uri: Mulesoft Anypoint platform URL
- muleVersion: Mulesoft version to be used for deployment(e.g. 4.2.3).
- username: Username for Anypoint platform.
- password: Password for Anypoint platform.
- businessGroup: Business group of the Anypoint platform under which you want to deploy your application.
- workers: The number of workers to be assigned to the application. This is used for horizontal scaling.
- workerType: The number of vCores to be assigned to the application. This is used for vertical scaling.
- region: Region to be used while deploying the application.
- environment: Environment onto which application needs to be deployed.
- applicationName: Application name to be deployed.
- properties: Provide here all the properties which are required by application at deployment time i.e. encryption key.
Step 2: Login into your Azure DevOps account. There are two ways to create a pipeline.
First, you can go to the Pipelines tab and click a new pipeline.
Or you can go to your repositories where you have your files and you can select the Build Pipeline option.
Let’s create it using the Create pipeline option.
Go to Pipeline and Create Pipeline.
Select Classic Editor as it gives better customization.
You can select your source where your code is stored. In my case, it’s in Azure Repos.
Further, select your Team Project, Repository and branch.
Then, click continue.
Select the Maven template.
This is the default screen you’ll see.
I’ll be removing all the three steps created under the Agent job and customize it according to my requirements.
Firstly, I am adding “Download secure file.” I’ll be using it to download settings.xml.
But to download and use secure file in our pipeline we need to store our file somewhere.
In order to add settings.xml go to Pipelines → Library → Secure files and add (+) Secure files.
On clicking + navigate to settings.xml:
Make sure your settings.xml has below server and profile added under the respective tags.
Now the settings which we created needs to be selected as below in our step.
Now let’s create a reference name “mulesoftSettingsFile” for this settings file which we are going to use later in maven goals.
Let’s add the next step in the Agent job, which will be Maven.
In Options, we have given the secure settings file a reference name which we created in the previous step.
We require "username" and "password" for the Anypoint platform to be provided at build time, so lets create two variables for them and pass it into the Maven setup for deployment.
Now let’s add the final Step which will be performed by our Agent.
Now let's run the pipeline. We can either save the pipeline using "Save" or save it and run using the "Save and run" option.
Once the pipeline gets completed executed you will see below screen.
And you will be able to see the application deployed onto CloudHub. We can add more steps into the CI/CD pipeline, like code analysis, testing, and report generation.
We have successfully created a CI/CD pipeline using Azure DevOps and deployed an application to CloudHub.
Opinions expressed by DZone contributors are their own.