DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Release Pipeline Using Azure DevOps
  • Mule 4 Continuous Integration Using Azure DevOps
  • DevOps Nirvana: Mastering the Azure Pipeline To Unleash Agility
  • How To Use AzureSignTool to Sign Executables With Azure DevOps

Trending

  • OpenAPI From Code With Spring and Java: A Recipe for Your CI
  • Observability in Spring Boot 4
  • Building an Image Classification Pipeline With Apache Camel and Deep Java Library (DJL)
  • The Agent Protocol Stack: MCP vs. A2A vs. AG-UI
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. DevOps and CI/CD
  4. Mulesoft Cloudhub Deployment using Azure DevOps

Mulesoft Cloudhub Deployment using Azure DevOps

This article gives a brief overview of Azure DevOps and the detailed steps on deploying a Mule application into Cloudhub.

By 
Pavithra Jothi user avatar
Pavithra Jothi
·
Aug. 17, 20 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
11.2K Views

Join the DZone community and get the full member experience.

Join For Free

Azure DevOps is a Microsoft SaaS platform that provides end to end DevOps toolchain for developing and deploying applications.

Here, we are going to implement an Azure pipeline for deploying Mule applications into Cloudhub.

Azure Repos is a repository for the source code which is managed by version control. We can have multiple repositories under a single project and multiple branches under each repository as per the requirement. Here is a sample project “DemoApp” under which there is a repository named “DemoApp”. It consists of a Mule application “demo-app-azure-DevOps”.

Edit pom.xml of the Mule application and include the below lines under both <repositories> and <distributionManagement> sections

XML
 




xxxxxxxxxx
1
10


 
1
<repository>  
2
     <id>xxxx</id>  
3
     <url>https://pkgs.dev.azure.com/xxxx/_packaging/xxxxx/maven/v1</url>
4
     <releases>  
5
        <enabled>true</enabled>  
6
     </releases>  
7
     <snapshots>
8
        <enabled>true</enabled>  
9
     </snapshots>
10
</repository>


article image
Also, include the following in pom.xml for Cloudhub Deployment. Refer this link for more details on each of the property — https://docs.mulesoft.com/mule-runtime/4.3/deploy-to-cloudhub 

XML
 




x


 
1
<plugin>
2
        <groupId>org.mule.tools.maven</groupId>
3
        <artifactId>mule-maven-plugin</artifactId>
4
        <version>3.3.5</version>
5
        <extensions>true</extensions>
6
        <configuration>
7
            <classifier>mule-application</classifier>
8
                    <cloudHubDeployment>
9
                        <uri>https://anypoint.mulesoft.com</uri>
10
                        <muleVersion>${mule.version}</muleVersion>
11
                        <username>${anypoint.username}</username>
12
                        <password>${anypoint.password}</password>
13
                        <environment>${cloudhub.environment}</environment>
14
                        <applicationName>${cloudhub.appName}</applicationName>
15
                        <workers>${cloudhub.workers}</workers>
16
                        <workerType>${cloudhub.workerType}</workerType>
17
                        <region>${cloudhub.region}</region>
18
                        <objectStoreV2>true</objectStoreV2>
19
                        <properties>
20
                            <mule.env>${mule.env}</mule.env>
21
                        </properties>
22
                    </cloudHubDeployment> 
23
        </configuration>
24
</plugin>



Creating Our First Build Pipeline

Goto Pipelines and click on New Pipeline

build pipeline

Select the appropriate Code repository

code repo


select a repo

Configure your Maven build pipeline

configure your repo

Then build the pipeline using the YAML file as shown below.  These are the step by step instructions for the pipeline configured:

  1. Pipeline gets triggered whenever the source code under the dev branch, under the path ‘demo-app-azure-DevOps/*’ changes.

  2. Maven Authentication is done to push the artifacts into a particular feed

  3. Pipeline caching is done to reduce the build time. Pipeline Caching can be implemented only on Build Pipelines and not on release pipelines. Create the below pipeline variables before building the pipeline

    Name

    Value

    MAVEN_CACHE_FOLDER

    $(Pipeline.Workspace)/.m2/repository

    MAVEN_OPTS 

    -Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)

  4. Maven task to read the pom file and deploy the artifacts. We have given the goal as deploy to push the jar into Azure artifacts

  5. Copy files task to copy the required files which can be used later

  6. Publish Build Artifact which publishes the required artifacts in the pipeline

YAML
 




x


 
1
# Maven
2
# Build your Java project and run tests with Apache Maven.
3
# Add steps that analyze code, save build artifacts, deploy, and more:
4
# https://docs.microsoft.com/azure/devops/pipelines/languages/java
5
 
6
trigger:
7
  branches:
8
    include:
9
    - dev
10
  paths:
11
    include:
12
    - 'demo-app-azure-devops/*'
13
 
14
pool:
15
  vmImage: 'ubuntu-latest'
16
 
17
steps:
18
- task: MavenAuthenticate@0
19
  inputs:
20
    artifactsFeeds: 'xxxxx'
21
- task: Cache@2
22
  inputs:
23
    key: 'maven | "$(Agent.OS)" | demo-app-azure-devops/pom.xml'
24
    path: '$(MAVEN_CACHE_FOLDER)'
25
    cacheHitVar: 'CacheRestored'
26
    restoreKeys: |
27
      maven | "$(Agent.OS)"
28
      maven
29
  displayName: Cache Maven local repo
30
- task: Maven@3
31
  inputs:
32
    mavenPomFile: 'demo-app-azure-devops/pom.xml'
33
    goals: 'deploy'
34
    publishJUnitResults: true
35
    testResultsFiles: '**/surefire-reports/TEST-*.xml'
36
    javaHomeOption: 'JDKVersion'
37
    mavenVersionOption: 'Default'
38
    mavenOptions: '-Xmx3072m $(MAVEN_OPTS)'
39
    mavenAuthenticateFeed: false
40
    effectivePomSkip: false
41
    sonarQubeRunAnalysis: false
42
- task: CopyFiles@2
43
  inputs:
44
    Contents: '**/target/*.jar'
45
    TargetFolder: '$(Build.ArtifactStagingDirectory)'
46
    CleanTargetFolder: true
47
    flattenFolders: true
48
- task: PublishBuildArtifacts@1
49
  inputs:
50
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
51
    ArtifactName: 'DemoApplication'
52
    publishLocation: 'Container'



Release Pipeline:

Once the build pipeline is completed, we can trigger the release pipeline as per requirements. Here is a sample release pipeline that gets triggered whenever the build pipeline is completed. This pipeline will deploy our application into Cloudhub.

Goto Pipelines -> Releases and create a New release pipeline

demoapp

Necessary artifacts must be added in the Artifacts section of the release pipeline to trigger it. In the below pipeline, we have configured the source build pipeline with the latest version. This configuration will pull up the artifacts which are built in the build pipeline.

azure devops

Also, enable the continuous trigger option to create releases every time a new build is done

continuous trigger

Then add Stages as per the environment to deploy and configure the tasks

download secure file

Download Secure file — Add the secure file under the Library section. The secure file should look like the below one. It can be configured according to the environment on which the Mule application should be deployed

JSON
 




x


 
1
{
2
 "Sandbox": {
3
  "username": "anypoint_platform_username",
4
  "password": "anypoint_platform_password",
5
  "organization": "xxxxx",
6
  "environment": "Sandbox",
7
  "host": ""
8
 }
9
}



demoapp


Bash Script — It includes Anypoint CLI commands to deploy the application into Cloudhub. Configure the below under the Script section. These commands are to deploy the application for the first time

JavaScript
 




x


 
1
npm install -g anypoint-cli@latest
2
mkdir ~/.anypoint
3
cp $AGENT_TEMPDIRECTORY/credentials ~/.anypoint/
4
export ANYPOINT_PROFILE=$(environment)
5

          
6
anypoint-cli runtime-mgr cloudhub-application deploy --runtime $(runtime) --workers $(workers) --workerSize $(workerSize) $(applicationName) $(applicationJarFilePath)



To redeploy the application into Cloudhub, make use of the below commands

JavaScript
 




x


 
1
npm install -g anypoint-cli@latest
2
mkdir ~/.anypoint
3
cp $AGENT_TEMPDIRECTORY/credentials ~/.anypoint/
4
export ANYPOINT_PROFILE=$(environment)
5

          
6
anypoint-cli runtime-mgr cloudhub-application modify --runtime $(runtime) --workers $(workers) --workerSize $(workerSize) $(applicationName) $(applicationJarFilePath)



Configure the below variables in the release pipeline or variable groups sections:

  • Environment — Environment under which to deploy the Mule application (say: Sandbox)
  • Runtime — Mule runtime (say: 4.3.0)
  • Workers — The number of workers to be assigned to the application. (say: 1)
  • WorkerSize — The number of vCores to be assigned to the application (say: 0.1)
  • ApplicationName — Mule application name (say: demo-application)
  • ApplicationJarFilePath — JAR file path which is located in the pipeline (say: D:/a/r1/a/_Mule Application Pipeline/DemoApplication/demo-app-azure-DevOps-1.0.2-SNAPSHOT-mule-application.jar)

deployment

Once the tasks are configured, we are ready to run and once the pipeline is successful, the application would be deployed to Cloudhub.

deployment with AnyPoint

We have successfully built our Azure pipeline to deploy the Mule application into Cloudhub.

Pipeline (software) application azure DevOps Build (game engine) Release (computing) Artifact (UML) MuleSoft

Opinions expressed by DZone contributors are their own.

Related

  • Release Pipeline Using Azure DevOps
  • Mule 4 Continuous Integration Using Azure DevOps
  • DevOps Nirvana: Mastering the Azure Pipeline To Unleash Agility
  • How To Use AzureSignTool to Sign Executables With Azure DevOps

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook