InterviewSolution
Saved Bookmarks
| 1. |
How can Jenkins facilitate Deployment in a DevOps practice? |
|
Answer» Jenkins auto-builds the source code from Git(any VCS) at every check-in; tests the source code and deploy the code in a tomcat environment via docker. WEBAPP source code is then DEPLOYED by tomcat server on a production environment. Pre-requisite:
Git project structure: Divya1@DIVYA:myWeb [master] $ Dockerfile webapp/ WEB-INF/ classes/ lib/ web.xml index.jsp --Dockerfile content: vi Dockerfile FROM tomcat:9.0.1-jre8-alpine ADD ./webapp /usr/local/tomcat/webapps/webapp CMD ["catalina.sh","run"]Add a new project in Jenkins and TRACK your git project url under SCM section.Have a dockerfile with the instruction to connect to the tomcat docker and deploy the webapp folder. --Add the build section to ‘execute shell’ as below: #!/bin/sh echo "Build started..." docker build -t webapp . echo "Deploying webapp to tomcat" docker run -p 8888:8080 webapp echo http://localhost:8888/webapp --Build the project from Jenkins:Below is the screenshot of the output: --CLICK on the link: http://localhost:8888/webapp |
|