pre-requisites:
1.
Make sure you configure maven installation under
Jenkins-->manage Jenkins-> Global Tool Configuration. under maven
installation. enter Maven3 as
name, enter path of maven installation --> /usr/share/maven and
uncheck install automatically option.
2. Also install SonarQube scanner, deploy
to container, Jacoco plugins under Jenkins --> Manage
Jenkins --> Manage plug-ins
Click on Available, type
Sonarqube, select SonarQube scanner. Click on Install without restart.
Repeat same for deploy to container and 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.
3. under source code
mgmt, click git. enter bit bucket URL. go to Bitbucket, select repo you created
from previous lab exercise , click on Clone and select HTTPS Url.
Copy it.
under credentials -->
click Add- > select Jenkins -->
Also make sure to remove
git clone trailing the url
4. select that from drop
down
Specify a branch or
leave as default */master
to build from master branch
.
5. under build trigger
click on poll scm, enter this value to check
for every 2 mins
--> H/02
* * * *
6. Build --> Add build step --> invoke
top level maven targets -->
select Maven3 from
drop down
enter goals as --> clean install
7. Click on advanced,
enter the path of POM file as --> MyWebApp/pom.xml
8. add Post build
action - select archive the artifacts
enter the below
value:(ignore if you get any error in red color)
**/*.war
there may be some errors
in red, but ignore it.
9.
click on Add post build action, select deploy war/ear to container
enter the same value
**/*.war
in WAR/EAR files, leave
context path empty
10. click
on Add container , select Tomcat 8.x
11. click
on add credentials, enter tomcat/password as
user name and password.
select it from drop down.
12. tomcat
url should be http://localhost:8090
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 bitbucket 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
http://public_dns_name_of_EC2:8090/MyWebApp
You
should see Hello World!!!
No comments:
Post a Comment