Table of Contents
- Prerequisites
- STEP 1 – Apache Tomcat 9
- STEP 2 – Jenkins
- STEP 3 – MuleSoft server and Anypoint platform setup
- STEP 4 – Generating Client ID and Client Secret using the connected apps
- STEP 5 – Maven Installation
- STEP 6 – Generating Git token to avoid MFA
- STEP 6 – Maven settings configuration
- STEP 6 – Updating POM to have the Jenkins configurations
- STEP 7 – Setting up Jenkins to run a new project
Prerequisites
- Make sure that Mule server is linked with Anypoint platform for On Prem.
- Git Bash is installed and running.
STEP 1 – Apache Tomcat 9
Download the Apache Tomcat 9 tar.gz from https://tomcat.apache.org/download-90.cgi
Extract and open the folder in Terminal.
Open the tomcat-users.xml which is available under apache-tomcat-9.0.89/conf folder and add the below content under tomcat-users:
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<user username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/>
Start Tomcat server from the bin directory.
STEP 2 – Jenkins
Download the Jenkins WAR file from https://www.jenkins.io/download/
Place the WAR file in the webapps folder of Apache Tomcat and restart the server.
Login to Jenkins at: http://localhost:8080/jenkins/login?from=%2Fjenkins%2F
Save the password generated and proceed with the setup process (username will be admin).
STEP 3 – MuleSoft server and Anypoint platform setup
- Download Mule standalone server and start it from the
binfolder. If you face any issues with permissions, go to System settings > Privacy & Security > Allow blocked script. - Add the server in Anypoint platform: Runtime Manager > Servers > Add new server > Execute the script generated in the
binfolder. - Restart the Mule server to get the server reflected on the platform.
STEP 4 – Generating Client ID and Client Secret using the connected apps
- Go to the Access Management in the Anypoint platform.
- Select Connected Apps and click on “Create App”.
- Select “App acts on its own behalf (client credentials)” and add all the scopes.
- Note down the generated Client ID and Client Secret.
STEP 5 – Maven Installation
Download Maven from Apache Maven website: https://archive.apache.org/dist/maven/maven-3/
Extract it and note down the path to set the environment variables.
Execute the below commands to set the Maven path:
export M2_HOME=/path/to/maven
export M2=$M2_HOME/bin
export MAVEN_OPTS="-Xms256m -Xmx512m"
export PATH=$M2:$PATH
Verify if the Maven path is set by using mvn -version command.
STEP 6 – Generating Git token to avoid MFA
- Login to GitHub and go to Settings > Developer Settings > Tokens (classic).
- Generate a new token and note it down.
STEP 6 – Maven settings configuration
Open settings.xml in the conf folder of Maven and add the following in the servers section:
<server>
<id>test</id>
<username>~~~Client~~~</username>
<password>your_password_here</password>
</server>
Add the following to the profiles section:
<profile>
<id>mule-ee</id>
<repositories>
<repository>
<id>mule-ee-releases</id>
<name>MuleEE Releases Repository</name>
<url>https://repository-master.mulesoft.org/nexus/content/repositories/releases-ee/</url>
</repository>
<repository>
<id>mule-ee-snapshots</id>
<name>MuleEE Snapshots Repository</name>
<url>https://repository-master.mulesoft.org/nexus/content/repositories/ci-snapshots/</url>
</repository>
<repository>
<id>MuleRepository</id>
<url>https://repository.mulesoft.org/nexus-ee/content/repositories/releases-ee/</url>
</repository>
<repository>
<id>MuleRepositoryPublic</id>
<url>https://repository.mulesoft.org/nexus/content/repositories/public</url>
</repository>
</repositories>
</profile>
STEP 6 – Updating POM to have the Jenkins configurations
On-Prem Deployment: Add the following under the configurations section:
<armDeployment>
<muleVersion>${app.runtime}</muleVersion>
<uri>https://anypoint.mulesoft.com</uri>
<target>${target}</target>
<targetType>${target.type}</targetType>
<server>${runtime.server}</server>
<environment>${environment}</environment>
<businessGroup>${businessGroup}</businessGroup>
<connectedAppClientId>${clientId}</connectedAppClientId>
<connectedAppClientSecret>${clientSecret}</connectedAppClientSecret>
</armDeployment>
CloudHub Deployment:
<cloudHubDeployment>
<uri>https://anypoint.mulesoft.com</uri>
<muleVersion>${app.runtime}</muleVersion>
<connectedAppClientId>${clientId}</connectedAppClientId>
<connectedAppClientSecret>${clientSecret}</connectedAppClientSecret>
<environment>${environment}</environment>
<workers>${workers}</workers>
<workerType>${workerType}</workerType>
</cloudHubDeployment>
STEP 7 – Setting up Jenkins to run a new project
- Make sure that Git is installed on your machine.
- Go to Jenkins Dashboard and click on “New Item”.
- Select “Freestyle project” and give it a relevant name.
- Under General, select “GitHub project” and give the project URL.
- Under Source Code Management, select Git and provide the repository URL.
- Mention branches to build, like
*/mainor*/dev. - Select Global credentials for authentication (Username and Git token).
- In Build steps, select “Invoke top-level Maven targets”.
- For On-Prem, give the following value in the Goals field:
- For CloudHub, give the following value:
- Click “Advanced” in Build steps and give your app name with
pom.xml(e.g.,test-app/pom.xml). - Save and build your application.
clean deploy -DmuleDeploy -Dtarget=mule-test-server -Denvironment=Design -DbusinessGroup=Test -DclientId=YOUR_CLIENT_ID -DclientSecret=YOUR_CLIENT_SECRET
clean deploy -DmuleDeploy -DclientId=YOUR_CLIENT_ID -DclientSecret=YOUR_CLIENT_SECRET -Dcloudhub.application.name=cloud-hub-app -Denvironment=Sandbox


Comments are closed