๐ ์ ํจ์ค๋
์ ํจ์ค๋ ์ํํธ์จ์ด ๊ฐ๋ฐ ์ ์ง์์ ํตํฉ(conticuous integration) ์๋น์ค๋ฅผ ์ ๊ณตํ๋ ํด์ด๋ค. ๋ค์์ ๊ฐ๋ฐ์๋ค์ด ํ๋์ ํ๋ก๊ทธ๋จ์ ๊ฐ๋ฐํ ๋ ๋ฒ์ ์ถฉ๋์ ๋ฐฉ์งํ๊ธฐ ์ํด ๊ฐ์ ์์ ํ ๋ด์ฉ์ ๊ณต์ ์์ญ์ ์๋ Git๋ฑ์ ์ ์ฅ์์ ๋น๋ฒํ ์ ๋ก๋ํจ์ผ๋ก์จ ์ง์์ ํตํฉ์ด ๊ฐ๋ฅํ๋๋ก ํด์ค๋ค.
๐ ์ ํจ์ค ์ค์น


- jenkins๋ฅผ ๊ตฌ๋ํ ํฌํธ๋ฅผ ์ค์ ํ๋ค.
- ๊ธฐ๋ณธ๊ฐ์ 8080์ด์ง๋ง ์ฌ์ฉ์ค์ผ ํ๋ฅ ์ด ๋์์ 80์ผ๋ก ํด์คฌ๋ค.

- jdk๊ฐ ์ค์น๋ java home ๊ฒฝ๋ก ์ค์
์ค์น๊ฐ ๋๋๋ฉด localhost:80์ ์ ์ํ ์ ์๊ฒ๋๋ค.

Set up
์๋ ๊ฒฝ๋ก๋ก ๋ค์ด๊ฐ initialAdminPassword๋ฅผ ๋ฉ๋ชจ์ฅ์ผ๋ก ์ด๊ณ ์ ๋ ฅ๋ ๋น๋ฐ๋ฒํธ๋ฅผ ๋ณต์ฌํ๋ค.
C:\ProgramData\Jenkins\.jenkins\secrets

๋น๋ฐ๋ฒํธ๋ฅผ localhost:80์ Administrator Password์ ๋ถ์ฌ๋ฃ์ผ๋ฉด ํ๋ฌ๊ทธ์ธ ์ค์น ์ฐฝ์ด ๋์จ๋ค.


Install suggested plugins๋ฅผ ์ ํํ๋ฉด ์ฌ๋งํ ํ๋ฌ๊ทธ์ธ์ ๋ฏธ๋ฆฌ ๋ค ์ค์น๋๋ค.
- O
์ค์น๊ฐ ๋ค ๋ํ์๋ Admin User๋ฅผ ๋ง๋ค๋๋ก ํ๋๋ฐ ์์ผ๋ก jenkins ๋ก๊ทธ์ธ์์ ์ฌ์ฉํ ๊ณ์ ์ ์ ๋ ฅํ๋ฉด๋๋ค.

์ฌ๊ธฐ๊น์ง ํ๋ฉด ์ ํจ์ค ์ค์น์ ์ ํจ์ค ์๋ฒ๊ฐ ๊ตฌ์ถ๋ ๋์๋ณด๋ ์ฐฝ์ ํ์ธํ ์ ์๋ค.

(์คํต๊ฐ๋ฅ) Jenkins ๊ด๋ฆฌ > ์์คํ ์ค์ ์ ๋ค์ด๊ฐ๋ฉด ๋งจ ์์ ํ ๋๋ ํ ๋ฆฌ ์ฃผ์๊ฐ๋ฌ๋ค. ์ด๊ฑธ ํ๊ฒฝ๋ณ์์ ์ถ๊ฐ

โก Git ์ฐ๋ํ๊ธฐ
๋จผ์ ๊น developer settings์์ personal token์ ๋ฐ์์ผํ๋ค.

ํ ํฐ์ผ๋ก ์ ๊ทผํ ์ ์๋ ๋ฒ์๋ฅผ ์ค์ ํ๋ค. ์ ๊ทผ ๋ฒ์๋ repo์ admin:repo_hook์ ์ ํํ๋ค.

Jenkins ๊ด๋ฆฌ > Manage Credential > Add Credentials๋ก ๋ค์ด๊ฐ์ ์ถ๊ฐํด์ค๋ค.


๊ทธ๋ผ crediential์ด ์์ฑ๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.

โจ Jenkins ํ๋ก์ ํธ ์์ฑ
ํ ์คํธ๋ฅผ ์ํด ๊ฐ๋จํ ๋ฌธ์์ด์ ๋ฐํํ๋ ํ๋ก์ ํธ๋ฅผ ์์ฑํ๋ค.
package com.jenkinstest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@GetMapping("/")
public String hello() {
return "hello";
}
}

build.gradle
// @SpringBootApplication์ด ์ค์ ๋ ํ์ผ
bootJar {
mainClassName = 'com.jenkintest.JenkinstestApplication'
}
bootRun {
String activeProfile = System.properties['spring.profiles.active']
systemProperty "spring.profiles.active", activeProfile
}
git์ ์ฌ๋ ค์ค๋ค.

gradle ํ๋ฌ๊ทธ์ธ์ ์ค์นํ๊ณ


gradle-wrapper.properties ์ ์๋ gradle ๋ฒ์ ์ผ๋ก Global Tool Configuration์ ์ค์ ํด์ค๋ค.
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

Jenkins์ github ์ฐ๊ฒฐ์ด ๋๋ฌ์ผ๋ฉด Jenkins์์ ํ๋ก์ ํธ๋ฅผ ์์ฑํ๋ค.




๋น๋ ํธ๋ฆฌ๊ฑฐ ์ค์
์๋ ๊ทธ๋ฆผ๊ณผ ๊ฐ์ด Build Triggers๋ฉ๋ด์์ Github hook trigger for GITScm polling ์ ์ ํํ๋ฉด Github์ ์ฝ๋๊ฐ ํธ์ฌ๋ ๋๋ง๋ค ๋น๋๋ฅผ ํธ๋ฆฌ๊ฑฐ๋ง ํ๋๋ก ์ค์ ํ ์ ์๋ค.

์ด๋ ๊ฒ ์ค์ ํ๋ฉด GitHub์์ ์ฝ๋ ์ฝ๋ ํธ์ฌ๊ณผ ๋ ๋ webHook ๋ฉ์ธ์ง๋ฅผ Jenkins์ ๋ณด๋ด์ฃผ๋๋ฐ ์ด WebHook๋ฉ์ธ์ง๋ฅผ ๋ฐ์ ๋๋ง๋ค ๋น๋๋ฅผ ํ๊ฒ๋๋ค.

