Logo

dev-resources.site

for different kinds of informations.

Deploying MuleSoft Application to Cloudhub 2.0 using Azure DevOps - Part 1

Published at
3/1/2023
Categories
mulesoft
azuredevops
tutorial
devops
Author
brunosouzas
Author
11 person written this
brunosouzas
open
Deploying MuleSoft Application to Cloudhub 2.0 using Azure DevOps - Part 1

This article we will talk about how to deploy a MuleSoft Application using Azure DevOps as a CI/CD tool with yaml file as scripts to reuse in any projects.

We will use Azure Repos as git repository to pipeline scripts and the MuleSoft application.

I'll split the full process in 2 articles, this article we will explore the deploy to develop environment and the next article we will explore the deploy to production environment.

Azure DevOps Project

Create a new Project in Azure DevOps with mulesoft-projects name

Importing Script Pipeline

After create your project in Azure DevOps, we need import the devops-scripts to azure repos.

Ps. Use the devops-scripts as repo name with main branch.

Azure DevOps Configuration

Now we will create the variables, you can navigate to Pipeline menu in your project and click on Library.

Azure DevOps

Variable Groups

Variable Groups are frequently used to store values that are desirable to make available across the pipelines. Additionally, they can be used to store secrets and credentials that are going to be needed into our build and release pipelines. We are going to create the following variable groups:

  • anypoint-platform-variables :

    • AnypointClientId - Specifies the Connected App clientID value
    • AnypointClientSecret - Specifies the Connected App secret key.
  • anypoint-platform-<ENVIRONMENT>-variables :

    • chEnv - Specifies the Cloudhub Environment Name
    • muleEnv - Specifies the Mule Environment used in your project
  • <APPLICATION NAME> :

    • encryptKey - encrypt key for production
    • encryptKeyNonProd - encrypt key for non-production

This variable is used to add common passwords used in all application, if you have to use dynamic properties, we'll talk about in another article how to add dynamic properties with parent-pom.

Azure DevOps

Connected App

Click here to learn how to create a Connected App at Anypoint Platform.

This is the scopes you need add to deploy process

Runtime Manager
Create Applications
Read Applications
General
View Environment
View Organization
Exchange
Exchange Contributor
Exchange Viewer

Secure Files

Secure Files can be used to encrypt valuable resources that will be needed during the build and release pipelines.

The Maven settings.xml file containing:

  • MuleSoft Enterprise Repository Nexus Credentials.
  • Connected APP to deploy

In devops-script repository has a template into /common folder

Add the settings.xml in secure file to be use in deploy process.

Azure DevOps

Deployment Steps

The pipeline will be triggered when you do a commit in develop branch, we're testing the code, creating an Artifact to use in Production deploy and do the deploy to develop environment.

The Release Pipeline is a manual process to deploy in production environment using the artifact created in develop steps with approvers.

The diagram below illustrates the concept:

Azure DevOps

Scripts

We have 2 main scripts in our process:

  • azure-pipelines.yml
  • mulesoft-jobs.yml

The script azure-pipeline.yml is in raw folder from MuleSoft application and contains the minimal configuration to start the process.

The script mulesoft-jobs.yml is in devops-scripts repository, is the common script with the steps of the deploy process.

MuleSoft Application

To this example you will import this example.

I project you have 2 important files:

  • azure-pipelines.yml
  • pom.xml

Azure-pipelines.yml



name: $(Date:yyyyMMdd).$(Rev:r)
resources:
  repositories:
  - repository: devops-scripts
    type: git
    name: mulesoft-projects/devops-scripts
    ref: refs/heads/main

trigger:
- develop
- release-\*

stages:
- template: mulesoft-jobs.yml@devops-scripts


Enter fullscreen mode Exit fullscreen mode

Name : This is the code you see every time you run the pipeline
Resources/Repositories : The repository used to call the template in stage
Trigger : the branches that will trigger
Stages/Template : main script yaml from process

Pom.xml

The configuration to deploy in Cloudhub



<cloudhub2Deployment>
ā€¦
</cloudhub2Deployment>


Enter fullscreen mode Exit fullscreen mode

The config to deploy in Anypoint Exchange



<distributionManagement>
ā€¦
</distributionManagement>


Enter fullscreen mode Exit fullscreen mode

If you need more details about deploy config using maven, click here

Creating Pipeline to your Application

Go to Pipelines and click in New Pipeline

Azure DevOps

Choose Azure Repos Git (YAML)

Azure DevOps

Choose the Mule Application Repository (hello-world)

Azure DevOps

You can see the azure-pipelines.yml, Click in Save

Azure DevOps

Now you can Run the Pipeline (use develop branch, the script has a rule to only deploy develop branch, to production we will use the Release Pipelines)

Azure DevOps

Azure DevOps

Now click in your pipeline to follow the steps and in your first time you need permit the access to Devops-scripts repository and variable group.

Azure DevOps

Azure DevOps

Config Slack/Teams to Azure DevOps

The notification doesn't in scripts, you need config your tools using the links below.

Slack
Microsoft Teams

Conclusion

This article does not have the complete deployment process, but the idea is to show how to deploy using the yaml file to reuse in other projects. I tried to use a simple idea using yaml scripts and I believe with this you can study and learn more.

In yaml script you will see a maven setup script, this script is due a MuleSoft issue with maven 3.9 in this moment (feb-2023).

Reference:
gitflow-workflow
Azure-DevOps

Code Source
devops-scripts
MuleSoft hello-world

mulesoft Article's
30 articles in total
Favicon
Top Use Cases of MuleSoft API Manager
Favicon
List of AsyncAPI servers in MuleSoft
Favicon
Comparison Of Boomi And Mulesoft: Choosing The Right Integration Platform
Favicon
MuleSoft RPA Basics: From Start to Finish
Favicon
Quick fix: com.github.everit-org.json-schema:org.everit.json.schema:jar:1.12.2 was not found
Favicon
The Ultimate Guide to Mastering MuleSoft: Elevate Your Integration Skills
Favicon
How to Improve Productivity with MuleSoft RPA Integration
Favicon
Integration Digest: March 2024
Favicon
4 ways to retrieve your OrgID/groupID from Anypoint Platform
Favicon
An interesting Mule app to create complex MUnits
Favicon
Methods for Handling Null Values in DataWeave
Favicon
Quick guide to applying MuleSoft's API Autodiscovery
Favicon
Quick guide to secure/encrypt your properties in MuleSoft
Favicon
Integration Digest: October 2023
Favicon
Integration Digest: November 2023
Favicon
mTLS in CloudHub 2.0 : What Developers Need to Know
Favicon
Harnessing the power of MuleSoft and Hasura
Favicon
How to Set HTTP Error Responses in MUnit Testing
Favicon
Quick reference: CI/CD for a Mule app using a Connected App
Favicon
Mastering RAML Resource Naming: Best Practices for a MuleSoft Marvel! šŸ’»šŸš€
Favicon
Leverage Exchange Mocking Service with Mocking Service Proxy
Favicon
Best Mulesoft Service Providers
Favicon
Using time() and duration() in DataWeave for performance check
Favicon
Deploying MuleSoft Application to Cloudhub 2.0 using Azure DevOps - Part 2
Favicon
Deploying MuleSoft Application to Cloudhub 2.0 using Azure DevOps - Part 1
Favicon
Main difference between 'do' and 'using' operators in DataWeave
Favicon
Develop your Battlesnake using a MuleSoft API & DataWeave with this starter project
Favicon
How to generate shareable link examples from GitHub to open in the DataWeave Playground
Favicon
Custom Alerts and Notifications in CloudHub 2.0
Favicon
Read this book to get started with MuleSoft! Especially if you come from a Salesforce background

Featured ones: