Implementing CI/CD In Mulesoft Using Jenkins Pipeline
MuleCraft Digital
An IT startup, that transforms data into powerful connections. We value efforts and uplift talents.
Introduction
Key Uses?
Jenkins is a popular CI/CD (Continuous Integration/Continuous Deployment) tool known for its versatility and automation capabilities. Here are three key uses of Jenkins in CI/CD:?
Automated Builds
Jenkins can automatically trigger and manage code builds whenever changes are pushed to a version control system like Git. It compiles, tests, and packages the code, ensuring that it's always in a deployable state.
Continuous Integration(CI)
Jenkins enables teams to integrate code changes frequently, helping identify and fix issues early in the development process. It runs automated tests and checks for code quality, ensuring that each integration doesn't introduce regressions.?
Continuous Deployment(CD)
Jenkins can automate the deployment process, allowing teams to release new versions of their software quickly and reliably. It can deploy applications to various environments, including development, staging, and production, with just a few clicks or based on predefined criteria.?
Functional Overview:?
?Why Jenkins is popular?
Core steps for Implementation
Jenkins Installation
GitLab configuration in Jenkins
Manage Jenkins>Credentials>System>Global credentials (unrestricted)>Add Credentials > Create??
Anypoint CloudHub configuration in Jenkins
Manage Jenkins>Credentials>System>Global credentials (unrestricted)>Add Credentials > Create?
Adding Jenkins file in Mule project
Step1:?Create a new file named “Jenkinsfile” under mule root project directory.?
Step2:?Add below mentioned script in your Jenkinsfile.?
pipeline{??
agent any?
stages{?
stage('Build Application') {?
steps {?
bat 'mvn clean install'?
}?
}?
stage('Deploy CloudHubs') {?
environment {?
ANYPOINT_CREDENTIALS = credentials(' anypointplatformcredentials ')?
}?
steps {?
echo 'Deploying mule project due to the latest code commit…'?
echo 'Deploying to the configured environment….'?
bat 'mvn clean deploy -DmuleDeploy?
-Dusername=${ANYPOINT_CREDENTIALS_USR} -
Dpassword=${ANYPOINT_CREDENTIALS_PSW}
-DworkerType=Micro -Dworkers=1'?
}??
}?
}?
}
Maven-plugin in pom.xml in Mule Project
Step1: Add the below mentioned plugin under?plugin under <build><plugins> tag?
<plugin>?
? <groupId>org.mule.tools.maven</groupId>?
? <artifactId>mule-maven-plugin</artifactId>?
? <version>${mule.maven.plugin.version}</version>
??<extensions>true</extensions>?
? <configuration>?
<cloudHubDeployment>?
???????? <uri>https://anypoint.mulesoft.com/</uri>?
???????? <muleVersion>${app.runtime}</muleVersion>?
???????? <username>${username}</username>?
???????? <password>${password}</password>?
???????? <applicationName>${project.artifactId}</applicationName>?
???????? <environment>Sandbox</environment>?
???????? <workerType>${workerType}</workerType>?
???????? <workers>1</workers>?
???????? <objectStoreV2>true</objectStoreV2>?
????? </cloudHubDeployment>?
? </configuration>?
</plugin>?
Step2: Commit the Jenkinsfile and pom.xml file in Gitlab?
Creating a Jenkins pipeline
Step1:?new item> enter new item name> select pipeline > Ok?
Step2: Scroll down till?pipeline> select pipeline script from SCM> select SCM value as?Git> provide git repository URL and select previously configured?global git credential?and branch?main?or customize the branch name where you want to implement CI/CD?
And click on save?
?Step3:?Click on Build Now and the build will start?
Step4:?And now you can check build status on console output?
Step5:?Now you can check status of your application in Anypoint Runtime Manager?
Conclusion:?
In conclusion, Jenkins stands as a beacon of innovation in the world of CI/CD. Its ability to automate, streamline, and accelerate every facet of the software development lifecycle has revolutionized the way teams build, test, and deploy software. Jenkins empowers developers to focus on crafting code, knowing that the robust automation it provides will ensure their work is integrated, tested, and deployed reliably.?
QA Automation Test Lead - Automation Architect - Selenium Java | Microfocus UFT | Virtuoso | UiPath |Product Testing | API Testing |Browser & Device Compatibility| CICD[Automation, Maven, Jenkins, GitHub]@ Cognizant
1 年This Artie was informative. ??