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
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Migrate, Modernize and Build Java Web Apps on Azure: This live workshop will cover methods to enhance Java application development workflow.

Modern Digital Website Security: Prepare to face any form of malicious web activity and enable your sites to optimally serve your customers.

Kubernetes in the Enterprise: The latest expert insights on scaling, serverless, Kubernetes-powered AI, cluster security, FinOps, and more.

A Guide to Continuous Integration and Deployment: Learn the fundamentals and understand the use of CI/CD in your apps.

Related

  • Getting Started With Jenkins
  • Beyond Jenkins: The Power of Cloud-Native AWS CodePipeline for Deployments
  • How To Use Docker Volume To Build Angular Application With Jenkins Pipeline
  • GitLab vs Jenkins: Which Is the Best CI/CD Tool?

Trending

  • Mastering Backpressure in Java: Concepts, Real-World Examples, and Implementation
  • Unlocking Clean Code: 20 Architectural Tips for Every Developer
  • The ABCs of Unity's Coroutines: From Basics to Implementation
  • Mastering Cloud Migration: Best Practices to Make it a Success
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Mule and Jenkins

Mule and Jenkins

Learn how Jenkins can be configured for continuous integration of Mule projects using Mule's out-of-the-box Maven plugins.

Anupam Gogoi user avatar by
Anupam Gogoi
·
Oct. 26, 17 · Tutorial
Like (3)
Save
Tweet
Share
14.8K Views

Join the DZone community and get the full member experience.

Join For Free

Mule provides out-of-the-box Maven plugins by means of which one can create a build that is triggered on every project change, and runs all its unit and functional tests automatically. In this article, I am going to show how easy it is to configure Jenkins for continuous integration of Mule projects.

Before We Start

Before we start be sure that you have already installed Jenkins in your system and it's up and running. In this tutorial I have put my conditions as follows. My project is checked-in in bitbucket and Jenkins will poll every minute to check if something new has been pushed to the repository. If it is true it will build the project and deploy it in the Cloudhub.

The Project Structure

The project must be a maven project. For this tutorial I am using a very simple project. Also I have created a property file to provide the following properties.

anypoint.username=YOUR ANYPOINT LOGIN
anypoint.password=YOUR ANYPOINT PASSWORD
anypoint.environment=Sandbox

I am using the properties in the pom.xml of the project. Here is the pom file,

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>com.ac</groupId>
<artifactId>maven-test</artifactId>
<version>1.0.0</version>
<packaging>mule</packaging>
<name>Mule maven-test Application</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<mule.version>3.8.4</mule.version>
<mule.tools.version>1.2</mule.tools.version>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-app-maven-plugin</artifactId>
<version>${mule.tools.version}</version>
<extensions>true</extensions>
<configuration>
<copyToAppsDirectory>true</copyToAppsDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-resource</id>
<phase>generate-resources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/main/app/</directory>
</resource>
<resource>
<directory>mappings/</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>

<!-- Read property file -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>src/main/resources/init.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
<!-- Deploy to Cloudhub -->
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<deploymentType>cloudhub</deploymentType>
<muleVersion>3.8.4</muleVersion>
<username>${anypoint.username}</username>
<password>${anypoint.password}</password>
<redeploy>true</redeploy>
<environment>${anypoint.environment}</environment>
<workerType>Micro</workerType>
</configuration>
<executions>
<execution>
<id>deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>

<!-- Mule Dependencies -->
<dependencies>


</dependencies>

<repositories>
<repository>
<id>Central</id>
<name>Central</name>
<url>http://repo1.maven.org/maven2/</url>
<layout>default</layout>
</repository>
<repository>
<id>mulesoft-releases</id>
<name>MuleSoft Releases Repository</name>
<url>http://repository.mulesoft.org/releases/</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>mulesoft-release</id>
<name>mulesoft release repository</name>
<layout>default</layout>
<url>http://repository.mulesoft.org/releases/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>mule-public</id>
<url>https://repository.mulesoft.org/nexus/content/repositories/releases</url>
</pluginRepository>
</pluginRepositories>

</project>

Jenkins Configuration

Now let's configure a Jenkins item for the application. 

Create Item

Create a Maven project as shown below,

Image title

General

Let's configure our bitbucket in the General section.

Image title

SCM

Provide the necessary credentials of bitbucket.

Image title

Build Triggers

Image title

Pre Steps

Image title

Note that the property values (starting with -D) that were defined in the pom.xml are being filled with proper values.

Test 

Now make some changes in the code and do a commit. The Jenkins job will start automatically and the application will be deployed/redeployed in the Cloudhub.


Conclusion

In this article I have shown how to configure Jenkins for continuous deployment of Mule projects in Cloudhub. In the next article I am going to show how to do it in on-premise Mule Runtime.

Jenkins (software)

Opinions expressed by DZone contributors are their own.

Related

  • Getting Started With Jenkins
  • Beyond Jenkins: The Power of Cloud-Native AWS CodePipeline for Deployments
  • How To Use Docker Volume To Build Angular Application With Jenkins Pipeline
  • GitLab vs Jenkins: Which Is the Best CI/CD Tool?

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

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 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: