Mule 4 Continuous Integration using Azure DevOps
GitHub repository with the project can be found at the end of the post.
Once we start developing applications in MuleSoft and we keep our code stored in any source control platform like Github, Bitbucket, GitLab, or Azure; as a developer and as a best practice, we look into automating the process to deploy our applications to either CloudHub or an On-Premise server.
In this post I will explain how a MuleSoft application can be automatically deployed into CloudHub or an On-Premise server from Azure DevOps as our main Continuous Integration (CI) and source control platform.
Creating a new project in Azure
The first step would be to setup our project in Azure DevOps, for this you need a Microsoft account. You can get one here.
Then, we can create a new project, provide a name and a description, as well as set the privacy settings. By default you can set it as "private".
Once it is created, we can go into the main page and locate the "Repos" section. Once we see the page, we can use the information to send our code directly from our local environment.
Just before actually pushing any code we can create a pretty simple endpoint that we can hit later to verify it’s all working. Let's create a simple RAML definition in Anypoint Platform:
Then we can generate the flows in our project. Right click on the RAML file > Mule > Generate Flows from Local REST API.
Once we have our flow generated, we can proceed to create our test.yaml file in order to identify any value we want to attach to our environment.
It will look just like this:
http: port: "8081" environment: "[TEST]"
I will create a "global.xml" configuration file to keep my configurations. I will add a Configuration Properties element:
After that, we can create a Global Property, in this case called env which will allow us to know which environment we are working on.
I know, a lot of steps, right? But let's try to make it right, just before our final check to verify everything is working. Let's add an environment variable called env in our Run Configuration.