Jenkins is popular open source Continuous integration tool. It was written entirely in Java. Jenkins is a self-contained automation server used for automating builds, tests and deployment.
See below the steps for configuring Jenkins to automate the build and deployment for the Java Web project we already set up in BitBucket into
pre-requisites:
- Java WebApp setup in BitBucket
- Jenkins is up and running
- Tomcat is up and running
- Make sure you configure maven installation under Jenkins-->manage Jenkins-> Global Tool Configuration. under maven installation. enter Maven3 as name and check install automatically option.
- Also install deploy to container, Jacoco plugins under Jenkins --> Manage Jenkins --> Manage plug-ins
Deploy to container
JaCoCo
Click on without restart.
steps to automate MyWebApp project in Jenkins:
1. Login to Jenkins. Click on New item.
2. Enter an item name --> select Free style project.
enter name as myFirstAutomateJob. click OK.
enter name as myFirstAutomateJob. click OK.
3. under source code mgmt, click git. enter Bitbucket URL
Click on your repo, Copy the url from the browser. Paste the url as Repository URL below.
Click on your repo, Copy the url from the browser. Paste the url as Repository URL below.
under credentials --> click Add- > select Jenkins --> enter your Bitbucket username and App password. DO NOT use BitBucket password as it is removed from March 1st, 2022. Click to here to learn how to generate App Password in Bitbucket. Add description as my SCM credentials.
4. select that from drop down.
6. under build trigger click on poll scm, enter this value to check
select Maven3 from drop down and goal as clean install
11. click on Add container , select Tomcat 9.x
12. click on add credentials, enter tomcat as user name and password as password.
select it from drop down.
click Apply, click Save
click on build now..It should build.
if there is any error, please check the console output. Most of the common error would be checking the path of Maven installation, valid credentials for GitHub or Tomcat. Also make sure you install the plug-ins.
After successful deployment, please make sure you check the output in Tomcat by going to browser and enter below URL
This is how you automate the builds and deployments using Jenkins.
Code Coverage Report can be seen in Jenkins as well. Click on Job name.
Please watch the steps in YouTube channel:
No comments:
Post a Comment