1. Tomcat Web application Manager 설정
Tomcat 서버에 war파일을 배포하려면 Tomcat Web application Manager 설정이 필요하다.
"Tomcat 설치 경로/conf/tomcat-users.xml"파일을 열어 계정을 추가하자.
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<tomcat-users xmlns="http://tomcat.apache.org/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
version="1.0">
<!--
NOTE: By default, no user is included in the "manager-gui" role required
to operate the "/manager/html" web application. If you wish to use this app,
you must define such a user - the username and password are arbitrary. It is
strongly recommended that you do NOT use one of the users in the commented out
section below since they are intended for use with the examples web
application.
-->
<!--
NOTE: The sample user and role entries below are intended for use with the
examples web application. They are wrapped in a comment and thus are ignored
when reading this file. If you wish to configure these users for use with the
examples web application, do not forget to remove the <!.. ..> that surrounds
them. You will also need to set the passwords to something appropriate.
-->
<!--
<role rolename="tomcat"/>
<role rolename="role1"/>
<user username="tomcat" password="<must-be-changed>" roles="tomcat"/>
<user username="both" password="<must-be-changed>" roles="tomcat,role1"/>
<user username="role1" password="<must-be-changed>" roles="role1"/>
-->
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<user username="admin" password="Q!w2e3r4t5" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/>
</tomcat-users>
</tomcat-users> 위에 role을 위와 같이 설정하고 user 설정을 한다.
설정 후 tomcat을 재기동한다.
혹여나 webpapps 폴더의 manager 폴더를 삭제하였다면 같은 버전의 tomcat 설치 파일을 다운로드하여서 webapps/manager 폴더를 서버의 webapps 폴더의 넣어주고 진행하자.
서버의 상의 webapps/manager/META-INF/context.xml을 열어서 아래와 같이 수정하자
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<Context antiResourceLocking="false" privileged="true" >
<!--
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
-->
<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>
서버의 상의 webapps/manager/WEB-INF/web.xml을 열어 war 파일의 용량 제한을 해제하자.
기본적으로 50mb가 설정되어 있어, 설정을 하지 않으면 50mb 보다 클 경우 배포가 불가능하다.
수정 후 톰캣을 재기동 해준다.
http://주소/manager/html에 접속하면
사용자와 비밀번호를 입력하는 창이 뜨는데, tomcat-users.xml에서 설정한 정보를 입력한다.
tomcat gui manager를 확인할 수 있다.
2. Jenkins Job 생성
배포를 위한 환경은 구성되었으니 war 빌드를 위한 job을 생성하자.
Dashboard에 새로운 Item을 선택하여 Job을 생성한다.
이름을 정해주고 "Freestyle project"를 선택하자.
소스 관리를 선택하여 SVN 정보를 입력하자.
Repository URL에 SVN 주소를 입력하고
Crentials의 Add를 눌러 SVN 계정 정보를 입력하자.
Username / Passwd / ID / Description을 입력하고 Add를 눌러 SVN 계정 정보를 입력한다.
비밀번호를 틀리면 Jenkins 전체 설정에서 다시 설정을 해야 하니, 신중을 기하자....
SVN 정보 설정이 끝났으면 배포에 대한 설정을 한다.
"빌드 후 조치 추가"에서 Deploy war/ear to a container를 선택하자.
"WAR/EAR files"에는 **/*. war를 넣어주자(빌드 시 특정 이름으로 생성하게 되어있다면 해당 사항을 기입한다. )
"Context path"에는 특정 경로에 배포되어야 하는 상황(Tomcat 서버에 Context-Path가 설정되어있는 경우 ) Context-이라면 해당 Context Path를 기입한다.
"Add Container"를 선택하여, 서버에 설치된 Tomcat x.x Remote를 선택한다.
Tomcat URL에는 Tomcat 서버의 접속 주소를 입력한다.
"Credentials"의 Add를 선택하여, 위에서 설정한 "Tomcat Web application Manager" 접속 정보를 추가하자.
입력을 다했으면, 저장을 하자.
Jenkins의 Dashboard를 보면 Deploy Dev 아이템이 추가되었다.
아이템의 이름을 클릭하고 상세 페이지로 가보자.
왼쪽 메뉴의 "Build Now"를 선택하면 설정된 구성으로 빌드를 진행한다.
메뉴 하단에 Build History에는 빌드를 진행한 내역, 빌드 중이라면 진행 내역을 확인할 수 있다.
#6에 마우스를 올리면 콤보 박스를 선택할 수 있는데,
"바뀐 점"을 선택하면 소스 변경내역을 확인할 수 있고,
Console Output을 선택하면 진행 중이거나, 진행되었던 Build 로그를 확인할 수 있다.
빌듯이 오류가 발생하였다면 해당 메뉴를 선택하여 오류 내용을 분석하면 된다.
'IT' 카테고리의 다른 글
IntelliJ Spring Boot 시작하기 (0) | 2021.07.28 |
---|---|
Jenkins 설정 (1) - Global 설정 (0) | 2021.05.28 |
Jenkins 설치 (0) | 2021.05.27 |