๋ชฉ์ฐจ

Git, Maven ์ค์ ๋ฐ ํ๋ก์ ํธ ์์ฑ
- Jenkins ๊ด๋ฆฌ ํญ โ Plugins์ ๋ค์ด๊ฐ์ Github๊ณผ Maven plugin์ ์ค์นํ๋ค. Gradle๋ก ์งํ ์์๋ plugin์ ์ค์นํ๊ณ ์์ ํ๋ก์ ํธ๋ฅผ Freestyle project๋ก ์ ํํ๋ฉด ๋๋ค.


- ์๋ก์ด item(project)๋ฅผ ๋ง๋ค๊ณ ์์ค์ฝ๋๋ฅผ ๊ฐ์ ธ์ฌ github ๋งํฌ๋ฅผ ๊ธฐ์ ํ๋ค.

- Maven๊ณผ ๊ด๋ จ๋ ์ค์ ํ์ผ์ธ pom.xml์ ๊ธฐ๋ฐ์ผ๋ก buildํ ์ ์๋๋ก ํ๊ณ build ์ต์
์ clean, compile, package๋ก ์ง์ ํ๋ค.
- clean : ๊ธฐ์กด์ buildํ ๊ฒ์ด ์๋ค๋ฉด ์ง์ด๋ค.
- compile : ์ปดํ์ผํ๋ค.
- package : pom.xml์ ๋ฑ๋ก๋ package ํ์(jar or war)์ ๋ฐ๋ผ ํจํค์งํ๋ค.

- build๋ฅผ ์ฑ๊ณต์ ์ผ๋ก ๋ง์น๊ณ workspace์ ๋ค์ด๊ฐ๋ฉด war ํ์ผ์ด ์ ์์ฑ๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.


Tomcat ์๋ฒ ์ฐ๋
- Tomcat ์๋ฒ์ ๋ณต์ฌํ ๋์์ ํ์ผ ํจํด์ ๊ธฐ์
ํ๋ค.
- **/*.war ๐ WAR files๋ค์ ์ ํํ๊ฒ ๋ค = ํ์ฅ์๊ฐ .war๋ก ์ค์ ๋์ด์๋ ๊ฒ ์ ํ
- tomcat ์ค์นํ์ ๋ deploy ๊ถํ์ ๊ฐ๋ ๊ณ์ ์ ๋ฐ๋ก ์ค์ ํด๋์๋ค. ์ด ๊ณ์ ์ credential์ ์ถ๊ฐํ๋ค.


- Tomcat URL์ http://[IP์ฃผ์]:8088/ ๋ก ์ค์ ํ๋ค. Docker ํํ๋ก ๊ธฐ๋ํ๊ธฐ ๋๋ฌธ์ 127.0.0.1๋ก ๊ธฐ์ ํ๋ฉด ์์ ์ด ๊ฐ์ง๊ณ ์๋ ๊ฒฝ๋ก๋ก ์ ์์ ์๋ํ๋ค. ๋ฐ๋ผ์ WAR file์ Jenkins๋ฅผ ํตํด Tomcat ์๋ฒ์ ๋ฐฐํฌํ๋ ค๋ฉด ๋ณธ์ธ์ OS (Docker Host)์ IP ์ฃผ์๋ฅผ ์ ๋ ฅํด์ผํ๋ค.

- build๋ฅผ ํ๋ฉด hello-world.war ํ์ผ์ด tomcat ์๋ฒ์ ์ ๋ณต์ฌ๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.

์ฃผ๊ธฐ์ ์ผ๋ก ์๋ build์์ผ ๋ณ๊ฒฝ ์ฌํญ ์ ๋ฐ์ดํธํ๊ธฐ
- Project โ Configure โ Build Trigger์์ ์ต์
์ ์ค์ ํ ์ ์๋ค.
- Build periodically : ์ฝ๋์ ๋ณ๊ฒฝ์ฌํญ์ด ์์ด๋ ๋ค์ buildํ๋ค.
- Poll SCM : commit์ ๋ํ ๋ด์ฉ์ด ์์ ๋๋ง ๋ค์ buildํ๋ค.
- GitHub hook trigger for GITScm polling : GitHub ์ ์ฅ์์ ์ฐ๋ํ์ฌ ์ด๋ฒคํธ๊ฐ ๋ฐ์ํ ๋๋ง๋ค ๋น๋ํ๋ค. ์ฃผ๊ธฐ์ ์ผ๋ก build X

- ์์ค์ฝ๋ ์์ ๋ด์ฉ์ commit ํ๊ณ ๋ฐ์ํ๋ฉด ์๋์ ์ผ๋ก build๊ฐ ์คํ๋๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.



'DevOps > โ๏ธ CI&CD' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[โ๏ธCI/CD] GitHub Actions - AWS CodeDeploy & S3 ์ด์ฉํด์ ๋ฐฐํฌ (0) | 2024.04.22 |
---|---|
[โ๏ธ CI/CD] CI/CD์ GitHub Actions ํ์ฉ๋ฒ (1) | 2024.04.19 |
[โ๏ธ CI/CD] Jenkins๋ฅผ ์ด์ฉํด ๋ฐฐํฌํ๊ธฐ 2 - ๋ค๋ฅธ ์๋ฒ (0) | 2024.01.26 |
[โ๏ธ CI/CD] CI/CD์ Jenkins (1) | 2024.01.23 |

Git, Maven ์ค์ ๋ฐ ํ๋ก์ ํธ ์์ฑ
- Jenkins ๊ด๋ฆฌ ํญ โ Plugins์ ๋ค์ด๊ฐ์ Github๊ณผ Maven plugin์ ์ค์นํ๋ค. Gradle๋ก ์งํ ์์๋ plugin์ ์ค์นํ๊ณ ์์ ํ๋ก์ ํธ๋ฅผ Freestyle project๋ก ์ ํํ๋ฉด ๋๋ค.


- ์๋ก์ด item(project)๋ฅผ ๋ง๋ค๊ณ ์์ค์ฝ๋๋ฅผ ๊ฐ์ ธ์ฌ github ๋งํฌ๋ฅผ ๊ธฐ์ ํ๋ค.

- Maven๊ณผ ๊ด๋ จ๋ ์ค์ ํ์ผ์ธ pom.xml์ ๊ธฐ๋ฐ์ผ๋ก buildํ ์ ์๋๋ก ํ๊ณ build ์ต์
์ clean, compile, package๋ก ์ง์ ํ๋ค.
- clean : ๊ธฐ์กด์ buildํ ๊ฒ์ด ์๋ค๋ฉด ์ง์ด๋ค.
- compile : ์ปดํ์ผํ๋ค.
- package : pom.xml์ ๋ฑ๋ก๋ package ํ์(jar or war)์ ๋ฐ๋ผ ํจํค์งํ๋ค.

- build๋ฅผ ์ฑ๊ณต์ ์ผ๋ก ๋ง์น๊ณ workspace์ ๋ค์ด๊ฐ๋ฉด war ํ์ผ์ด ์ ์์ฑ๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.


Tomcat ์๋ฒ ์ฐ๋
- Tomcat ์๋ฒ์ ๋ณต์ฌํ ๋์์ ํ์ผ ํจํด์ ๊ธฐ์
ํ๋ค.
- **/*.war ๐ WAR files๋ค์ ์ ํํ๊ฒ ๋ค = ํ์ฅ์๊ฐ .war๋ก ์ค์ ๋์ด์๋ ๊ฒ ์ ํ
- tomcat ์ค์นํ์ ๋ deploy ๊ถํ์ ๊ฐ๋ ๊ณ์ ์ ๋ฐ๋ก ์ค์ ํด๋์๋ค. ์ด ๊ณ์ ์ credential์ ์ถ๊ฐํ๋ค.


- Tomcat URL์ http://[IP์ฃผ์]:8088/ ๋ก ์ค์ ํ๋ค. Docker ํํ๋ก ๊ธฐ๋ํ๊ธฐ ๋๋ฌธ์ 127.0.0.1๋ก ๊ธฐ์ ํ๋ฉด ์์ ์ด ๊ฐ์ง๊ณ ์๋ ๊ฒฝ๋ก๋ก ์ ์์ ์๋ํ๋ค. ๋ฐ๋ผ์ WAR file์ Jenkins๋ฅผ ํตํด Tomcat ์๋ฒ์ ๋ฐฐํฌํ๋ ค๋ฉด ๋ณธ์ธ์ OS (Docker Host)์ IP ์ฃผ์๋ฅผ ์ ๋ ฅํด์ผํ๋ค.

- build๋ฅผ ํ๋ฉด hello-world.war ํ์ผ์ด tomcat ์๋ฒ์ ์ ๋ณต์ฌ๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.

์ฃผ๊ธฐ์ ์ผ๋ก ์๋ build์์ผ ๋ณ๊ฒฝ ์ฌํญ ์ ๋ฐ์ดํธํ๊ธฐ
- Project โ Configure โ Build Trigger์์ ์ต์
์ ์ค์ ํ ์ ์๋ค.
- Build periodically : ์ฝ๋์ ๋ณ๊ฒฝ์ฌํญ์ด ์์ด๋ ๋ค์ buildํ๋ค.
- Poll SCM : commit์ ๋ํ ๋ด์ฉ์ด ์์ ๋๋ง ๋ค์ buildํ๋ค.
- GitHub hook trigger for GITScm polling : GitHub ์ ์ฅ์์ ์ฐ๋ํ์ฌ ์ด๋ฒคํธ๊ฐ ๋ฐ์ํ ๋๋ง๋ค ๋น๋ํ๋ค. ์ฃผ๊ธฐ์ ์ผ๋ก build X

- ์์ค์ฝ๋ ์์ ๋ด์ฉ์ commit ํ๊ณ ๋ฐ์ํ๋ฉด ์๋์ ์ผ๋ก build๊ฐ ์คํ๋๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.



'DevOps > โ๏ธ CI&CD' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[โ๏ธCI/CD] GitHub Actions - AWS CodeDeploy & S3 ์ด์ฉํด์ ๋ฐฐํฌ (0) | 2024.04.22 |
---|---|
[โ๏ธ CI/CD] CI/CD์ GitHub Actions ํ์ฉ๋ฒ (1) | 2024.04.19 |
[โ๏ธ CI/CD] Jenkins๋ฅผ ์ด์ฉํด ๋ฐฐํฌํ๊ธฐ 2 - ๋ค๋ฅธ ์๋ฒ (0) | 2024.01.26 |
[โ๏ธ CI/CD] CI/CD์ Jenkins (1) | 2024.01.23 |