카이도스의 Tech Blog
Jenkins를 이용한 CI/CD Pipeline - 2 본문
728x90
반응형
2025.01.23 - [CI CD] - Jenkins를 이용한 CI/CD Pipeline - 1
사전 준비 : Tomcat 설치
# 사전 준비
docker pull tomcat:9.0
docker history tomcat:9.0
docker history tomcat:9.0 --format json --no-trunc | jq
docker run -d --name tomcat -p 8081:8080 tomcat:9.0
docker ps
docker cp tomcat:/usr/local/tomcat/webapps.dist/ .
docker cp tomcat:/usr/local/tomcat/conf/tomcat-users.xml .
docker rm -f tomcat
# 접근 엑세스 변경 : 로컬 접속 부분 주석 처리
## %TOMCAT_HOME%\webapps\manager\META-INF\context.xml
vi ~/webapps.dist/manager/META-INF/context.xml
<!--Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /-->
## %TOMCAT_HOME%\webapps\host-manager\META-INF\context.xml
vi ~/webapps.dist/host-manager/META-INF/context.xml
<!--Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /-->
# 유저 추가 : %TOMCAT_HOME%\conf\tomcat-users.xml : 49번~ 하단까지 삭제 후 아래 입력
vi ~/tomcat-users.xml
<role rolename="manager-gui" />
<role rolename="manager-script" />
<role rolename="manager-jmx" />
<role rolename="manager-status" />
<user username="admin" password="admin" roles="manager-gui, manager-script, manager-jmx, manager-status"/>
<user username="deployer" password="deployer" roles="manager-script"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>
</tomcat-users>
# 다시 실행
docker run -d --name tomcat -p 8081:8080 -v ~/webapps.dist:/usr/local/tomcat/webapps -v ./tomcat-users.xml:/usr/local/tomcat/conf/tomcat-users.xml tomcat:9.0
docker ps
# http://IP:8081 웹 접속
ip -br -4 addr show dev eth0 | awk '{print $3}' | cut -d '/' -f1 | awk '{ print "Tomcat = http://"$1":8081" }'
ip -br -4 addr show dev ens18 | awk '{print $3}' | cut -d '/' -f1 | awk '{ print "Tomcat = http://"$1":8081" }'
- Tomcat 웹 접속 후 ‘Manage App’ 클릭 → tomcat / tomcat 계정 암호 입력 후 웹 애플리케이션 매니저 확인 ⇒ 애플리케이션 확인
Setup Git plugin : maven 설정
- Jenkins 관리 → Plugins → Installed plugins → Github plugin 확인
- 관리 → Tools ⇒ Git installations 확인
- Maven Integration 플러그인 설치
- Maven 설정
docker exec -it jenkins-server mvn --version
Apache Maven 3.8.7
Maven home: /usr/share/maven
Java version: 17.0.13, vendor: Eclipse Adoptium, runtime: /opt/java/openjdk
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "6.8.0-51-generic", arch: "amd64", family: "unix"
Jenkins Job : Item My-Second-Project
- Item 생성 : My-Second-Project , Maven project
- General : My maven project build
- 소스 코드 관리 : Git → Repo URL https://github.com/joneconsulting/cicd-web-project
- Build : Root POM(pom.xml) , Goals and options (clean compile package)
지금 빌드
- 콘솔 출력 확인
- 워크스페이스 작업공간에서 war 파일 확인
#
docker exec -it jenkins-server ls -l /var/jenkins_home/workspace/My-Second-Project/target
total 7840
drwxr-xr-x 3 jenkins jenkins 36 Jan 23 03:03 classes
drwxr-xr-x 3 jenkins jenkins 25 Jan 23 03:03 generated-sources
drwxr-xr-x 3 jenkins jenkins 30 Jan 23 03:03 generated-test-sources
drwxr-xr-x 4 jenkins jenkins 37 Jan 23 03:03 hello-world
-rw-r--r-- 1 jenkins jenkins 8025949 Jan 23 03:03 hello-world.war
drwxr-xr-x 2 jenkins jenkins 28 Jan 23 03:03 maven-archiver
drwxr-xr-x 3 jenkins jenkins 35 Jan 23 03:03 maven-status
drwxr-xr-x 2 jenkins jenkins 99 Jan 23 03:03 surefire-reports
drwxr-xr-x 3 jenkins jenkins 17 Jan 23 03:03 test-classes
Setup Tomcat Plugin : Jenkins Plugins → Available plugins → Deploy to container 설치
728x90
반응형
'CI CD' 카테고리의 다른 글
Jenkins를 이용한 CI/CD Pipeline - 1 (2) | 2025.01.23 |
---|---|
Sonarqube Upgrade (2) | 2024.02.27 |
Sonarqube 설치 (0) | 2024.02.27 |
jenkins 설치 (0) | 2024.02.26 |
Comments