[CI/CD] Jenkins์™€ Gitlab ์—ฐ๋™

2023. 10. 30. 20:05ใ†System ์ž‘์—…์‹ค/DevOps

728x90
๋ฐ˜์‘ํ˜•

 

 

 

COUPANG

์ฟ ํŒก์€ ๋กœ์ผ“๋ฐฐ์†ก

www.coupang.com

"์ด ํฌ์ŠคํŒ…์€ ์ฟ ํŒก ํŒŒํŠธ๋„ˆ์Šค ํ™œ๋™์˜ ์ผํ™˜์œผ๋กœ, ์ด์— ๋”ฐ๋ฅธ ์ผ์ •์•ก์˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ์ œ๊ณต๋ฐ›์Šต๋‹ˆ๋‹ค."

 



๐Ÿ—‚ ๋ชฉ์ฐจ


โœ…[CI/CD] Jenkins์™€ Gitea ์—ฐ๋™

โœ… [CI/CD] Jenkins์™€ Gitlab ์—ฐ๋™
โœ…[CI/CD] Jenkins Trigger ์ •๋ณด Discord๋กœ ๋ณด๋‚ด๊ธฐ
โœ…[CI/CD] ์ •์  ์ฝ”๋“œ ๋ถ„์„ ํˆด SonarQube์™€ Jenkins ์—ฐ๋™
โœ…[CI/CD] SonarQube๋ฅผ ํ†ตํ•ด Code Convention ์ ์šฉ
โœ…[DevOps] JAVA Gradle JaCoCo (Code coverage) ์„ค์ •ํ•˜๊ธฐ
โœ…[DevOps] JAVA Gradle JaCoCo (Code coverage) ์„ค์ •ํ•˜๊ธฐ (์ถ”๊ฐ€)
โœ…[CI/CD] Jenkins + Docker๋ฅผ ์ด์šฉํ•œ ๋ฌด์ค‘๋‹จ ๋ฐฐํฌ - โ‘  Application Linuxt(Ubuntu)์— SSH๋ฅผ ์ด์šฉํ•œ ํŒŒ์ผ ์ „์†ก
โœ…[CI/CD] Jenkins + Docker๋ฅผ ์ด์šฉํ•œ ๋ฌด์ค‘๋‹จ ๋ฐฐํฌ - โ‘ก Create Docker Image And BackUp
โœ…[CI/CD] Jenkins + Docker๋ฅผ ์ด์šฉํ•œ ๋ฌด์ค‘๋‹จ ๋ฐฐํฌ - โ‘ข Application Server Docker Job โ‘  Application ๋„์ปค ์กด์žฌ ์—ฌ๋ถ€ ํ™•์ธ)
โœ…[CI/CD] Jenkins + Docker๋ฅผ ์ด์šฉํ•œ ๋ฌด์ค‘๋‹จ ๋ฐฐํฌ - โ‘ข Application Server Docker Job (โ‘ก Application Docker Run)
โœ…[CI/CD] Jenkins + Docker๋ฅผ ์ด์šฉํ•œ ๋ฌด์ค‘๋‹จ ๋ฐฐํฌ - โ‘ข Application Server Docker Job(โ‘ข Application Docker Health Check)

โœ…[CI/CD] Jenkins + Docker๋ฅผ ์ด์šฉํ•œ ๋ฌด์ค‘๋‹จ ๋ฐฐํฌ - โ‘ฃ NGINX Server Docker Job (โ‘  NGINX ๊ฐ ์ข… ์„ค์ •)
โœ…[CI/CD] Jenkins + Docker๋ฅผ ์ด์šฉํ•œ ๋ฌด์ค‘๋‹จ ๋ฐฐํฌ - โ‘ฃ NGINX Server Docker Job (โ‘ก NGINX Docker ์กด์žฌ ์—ฌ๋ถ€ ํ™•์ธ)
โœ…[CI/CD] Jenkins + Docker๋ฅผ ์ด์šฉํ•œ ๋ฌด์ค‘๋‹จ ๋ฐฐํฌ -โ‘ฃNGINX Server Docker Job(โ‘ข NGINX Docker Run & Health Check)
โœ…[CI/CD] Jenkins + Docker๋ฅผ ์ด์šฉํ•œ ๋ฌด์ค‘๋‹จ ๋ฐฐํฌ - โ‘ฃ NGINX Server Docker Job (โ‘ข NGINX ์žฌ ์„ค์ •)





๐Ÿค” ๋‚ด๊ฐ€ ๋งŒ๋‚œ ๋ฌธ์ œ

โ›”๏ธ [Jenkins] java.lang.OutOfMemoryError: Java heap space

 

 

 

 

๐Ÿš€ ๊ฒŒ์‹œํŒ ๋งŒ๋“ค๊ธฐ - ์‚ญ์ œ

    ๐Ÿ”ฝ  ๊ฐœ์š”

        ๐Ÿ“ฆ ์†Œ๊ฐœ

์•ˆ๋…•ํ•˜์„ธ์š”? ์ด ์ „์— ์ฃผ๋‹ˆ๋Š” Jenkins์™€ Gitea๋ฅผ ์—ฐ๋™ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ํ†ตํ•ด CI/CD๋ฅผ ํ•  ์ˆ˜ ์žˆ๋„๋ก ๊ตฌ์„ฑํ•ด ๋ณด์•˜์–ด์š”.

 

[CI/CD] Jenkins์™€ Gitea ์—ฐ๋™

์  ํ‚จ์Šค ๋งˆ์Šคํ„ฐ COUPANG www.coupang.com "์ด ํฌ์ŠคํŒ…์€ ์ฟ ํŒก ํŒŒํŠธ๋„ˆ์Šค ํ™œ๋™์˜ ์ผํ™˜์œผ๋กœ, ์ด์— ๋”ฐ๋ฅธ ์ผ์ •์•ก์˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ์ œ๊ณต๋ฐ›์Šต๋‹ˆ๋‹ค." ๐Ÿ—‚ ๋ชฉ์ฐจ โš ๏ธ ์•„๋ž˜ ๋ชฉ์ฐจ ์ค‘ ๋ช‡๋ช‡๊ฐœ์˜ ๋งํฌ๊ฐ€ ๊ฑธ๋ฆฌ์ง€ ์•Š๋Š” ๋ฌธ์ œ๋กœ

junyharang.tistory.com

 

ํ•˜.์ง€.๋งŒ ์‹ค๋ฌด์—์„œ Gitea๋ฅผ ์“ฐ๋Š” ๊ณณ์€ ๋งŽ์ง€ ์•Š์„ ๊ฒƒ์œผ๋กœ ์‚ฌ๋ฃŒ๋˜๊ณ , ํ˜„์žฌ ๋ณด์œ ํ•œ ์„œ๋ฒ„์— ์ž์›์ด ๋„‰๋„‰ํ•ด์„œ Gitlab-CE๋ฅผ ๋‚ด๋ถ€ ์„œ๋ฒ„์— ์„ค์น˜ํ•˜๊ณ , Jenkins์™€ ์—ฐ๋™ํ•ด ๋ณด๋ ค๊ณ  ํ•ด์š”.

Gitlab์€ ์ด๋ ‡๊ฒŒ ์„ค์น˜ํ–ˆ์–ด์š”.


 

[Ubuntu] Docker gitlab ์„ค์น˜

(์˜๋ฌธ๋„์„œ) Automating DevOps with GitLab CI/CD Pipelines: Build efficient CI/CD pipelines to verify sec... Paperback COUPANG www.coupang.com "์ด ํฌ์ŠคํŒ…์€ ์ฟ ํŒก ํŒŒํŠธ๋„ˆ์Šค ํ™œ๋™์˜ ์ผํ™˜์œผ๋กœ, ์ด์— ๋”ฐ๋ฅธ ์ผ์ •์•ก์˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ์ œ๊ณต๋ฐ›

junyharang.tistory.com

 

 

 

[Gitlab][CI/CD] GitLab Runner ์„ค์น˜

(์˜๋ฌธ๋„์„œ) Automating DevOps with GitLab CI/CD Pipelines: Build efficient CI/CD pipelines to verify sec... Paperback COUPANG www.coupang.com "์ด ํฌ์ŠคํŒ…์€ ์ฟ ํŒก ํŒŒํŠธ๋„ˆ์Šค ํ™œ๋™์˜ ์ผํ™˜์œผ๋กœ, ์ด์— ๋”ฐ๋ฅธ ์ผ์ •์•ก์˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ์ œ๊ณต๋ฐ›

junyharang.tistory.com

 

 

 

    ๐Ÿ”ฝ Jenkins  & GitLab ์ดˆ๊ธฐ ๊ตฌ์„ฑ

        ๐Ÿ“ฆ Gitlab SSH ์—ฐ๊ฒฐ ๊ตฌ์„ฑ

์ตœ์ดˆ Client์—์„œ Gitlab์— ์—ฐ๊ฒฐํ•  ๋•Œ, SSH๋ฅผ ์ด์šฉํ•œ Key ๊ฐ’์œผ๋กœ ์—ฐ๊ฒฐ์ด ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•ด ์ž‘์—…์„ ํ•ด ๋ณผ๊ฒŒ์š”.


์ฃผ๋‹ˆ๋Š” ์œ„์™€ ๊ฐ™์ด ๋„์ปค๋ฅผ ์ด์šฉํ•ด์„œ ์  ํ‚จ์Šค๋ฅผ ์„ค์น˜ํ•ด ์ฃผ์—ˆ์–ด์š”. ๋„์ปค๋ฅผ ์ด์šฉํ•œ ์  ํ‚จ์Šค ์„ค์น˜ ๋ฐฉ๋ฒ•์€ ์ด๋ ‡๊ฒŒ ํ–ˆ์–ด์š”.

 

[๊ฐ€์ƒํ™” - Container] Docker๋ฅผ ์ด์šฉํ•œ Jenkins ์„ค์น˜

์  ํ‚จ์Šค ๋งˆ์Šคํ„ฐ COUPANG www.coupang.com "์ด ํฌ์ŠคํŒ…์€ ์ฟ ํŒก ํŒŒํŠธ๋„ˆ์Šค ํ™œ๋™์˜ ์ผํ™˜์œผ๋กœ, ์ด์— ๋”ฐ๋ฅธ ์ผ์ •์•ก์˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ์ œ๊ณต๋ฐ›์Šต๋‹ˆ๋‹ค." ๐Ÿš€ Docker๋ฅผ ์ด์šฉํ•œ Jenkins ์„ค์น˜ ๐Ÿ”ฝ Ubuntu 22.04.05 LTS Server ๐Ÿ“ฆ Jenkins ์„ค

junyharang.tistory.com

 

์  ํ‚จ์Šค์—์„œ Gitlab์— ์—ฐ๊ฒฐ์„ ํ•ด์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์œ„ ์ปจํ…Œ์ด๋„ˆ์— ์ ‘์†ํ•ด์„œ ์ž‘์—…ํ•ด ์ค„๊ฒŒ์š”.

docker exec -it <Container ID> /bin/bash


์œ„ ๋ช…๋ น์–ด๋Š” Container์— ๋ช…๋ น์–ด๋ฅผ ์ „๋‹ฌํ•˜๋Š”๋ฐ, /bin/bash ๋ผ๋Š” ๋ช…๋ น์–ด๋ฅผ ์ „๋‹ฌํ•˜์—ฌ
Shell์„ ์–ป์–ด์˜ค๋„๋ก ํ•ด ์ฃผ๋Š” ๋ช…๋ น์–ด์—์š”.

 

apt-get update && apt-get upgrade


git Package๋ฅผ ์„ค์น˜ํ• ๊ฑด๋ฐ, ์„ค์น˜ํ•˜๊ธฐ ์•ž ์จ ์œ„์™€ ๊ฐ™์ด ํŒจํ‚ค์ง€๋ฅผ ์ตœ์‹ ํ™” ํ•ด ์ฃผ์—ˆ์–ด์š”.

 

apt-get install git


์ฃผ๋‹ˆ๋Š” ์ด๋ฏธ ์„ค์น˜๊ฐ€ ๋˜์–ด ์žˆ์œผ๋‚˜, ์„ค์น˜๊ฐ€ ๋˜์–ด์žˆ์ง€ ์•Š์„ ์ˆ˜ ์žˆ์œผ๋‹ˆ ์œ„์™€ ๊ฐ™์ด ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•ด ์ฃผ์—ˆ์–ด์š”.

 

adduser jenkins_admin


์ตœ์ดˆ ์œ„์™€ ๊ฐ™์ด ๋‹ค๋ฅธ ์„œ๋น„์Šค์—์„œ ์ ‘์†ํ•˜์—ฌ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๊ณ„์ •์„ ๋งŒ๋“ค์–ด ์ฃผ์—ˆ์–ด์š”.

 

ssh-keygen -t ed25519 -C "<gitlab Email ๊ณ„์ •>"

728x90

์œ„์™€ ๊ฐ™์ด SSH ์ ‘์†์šฉ ์„œ๋ช… Key ์Œ์„ ์ƒ์„ฑํ•ด ์ฃผ์—ˆ์–ด์š”. 

- Enter file in which to save the key (/root/.ssh/id_ed25519): ์ด ๋ถ€๋ถ„์€ Key ํŒŒ์ผ์ด ์ €์žฅ๋  ์œ„์น˜๋ฅผ ๋ฌป๋Š” ๊ณณ์œผ๋กœ Default Path๋Š” ํ•ด๋‹น ๊ณ„์ • Home Directory ๋ฐ‘์— .ssh ์ž…๋‹ˆ๋‹ค.

- Enter passphrase (empty for no passphrase): ์ด ๋ถ€๋ถ„์€ ํ•ด๋‹น Key ํŒŒ์ผ์˜ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜๋Š” ๋ถ€๋ถ„์ด์—์š”. ๋งŒ์•ฝ ์ž…๋ ฅํ•œ๋‹ค๋ฉด ์—ฐ๋™ ์‹œ ๋ฐ˜๋“œ์‹œ ํ•„์š”ํ•˜๋‹ˆ ์ ์–ด๋‘๋Š”๊ฒŒ ์ข‹๊ณ , ํ•„์š”์—†๋‹ค๋ฉด ๊ทธ๋ƒฅ ์—”ํ„ฐ๋ฅผ ๋ˆ„๋ฅด๊ณ  ๋„˜์–ด๊ฐ€๋ฉด ๋ฉ๋‹ˆ๋‹ค.

- Enter same passphrase again: 2๋ฒˆ์—์„œ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ–ˆ๋‹ค๋ฉด ๋‹ค์‹œ ํ•œ๋ฒˆ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•œ ๋ถ€๋ถ„์ด์—์š”.

 

chmod 700 ~/.ssh/id_ed25519*


๋งŒ๋“  ํ‚ค ์Œ์— ๋Œ€ํ•ด ๊ถŒํ•œ์„ ์ˆ˜์ •ํ•ด ์ฃผ์—ˆ์–ด์š”. jenkins_admin ์ด๋ผ๋Š” ์‚ฌ์šฉ์ž๋งŒ ์ฝ๊ธฐ, ์“ฐ์‹œ, ์‹คํ–‰ ๊ถŒํ•œ์„ ์ฃผ์—ˆ์–ด์š”.

 

cat ~/.ssh/id_ed25519.pub


์ด๋ ‡๊ฒŒ cat ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ๋งŒ๋“ค์–ด์ง„ ํ‚ค ์Œ ์ค‘ ๊ณต๊ฐœํ‚ค๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋Š”๋ฐ,
์ด ๊ณต๊ฐœํ‚ค๋ฅผ gitlab์— ๋“ฑ๋ก ์‹œ์ผœ ์ฃผ์‹œ ์œ„ํ•ด์„œ ๋ชจ๋“  ๋ถ€๋ถ„์„ ๋‹ค ๋ณต์‚ฌํ•ด ์ค„๊ฒŒ์š”. 

 

 

        ๐Ÿ“ฆ Gitlab ์—ฐ๊ฒฐ

gitlab์— ์ ‘์†ํ•œ ๋’ค ์œ„์™€ ๊ฐ™์ด ํ”„๋กœํ•„ ํŽธ์ง‘(Edit profile)์„ ๋ˆŒ๋Ÿฌ ์ค๋‹ˆ๋‹ค.

 


SSH ํ‚ค(SSH Keys)
๋ฅผ ๋ˆŒ๋Ÿฌ ์ค๋‹ˆ๋‹ค.


์—ฌ๊ธฐ์„œ ์ƒˆ ํ‚ค ์ถ”๊ฐ€๋ฅผ ๋ˆŒ๋Ÿฌ ํ‚ค๋ฅผ ์ถ”๊ฐ€ํ•ด ์ค„๊ฒŒ์š”.


์œ„์™€ ๊ฐ™์ด ์  ํ‚จ์Šค ์„œ๋ฒ„์—์„œ ๋งŒ๋“  ๊ณต๊ฐœํ‚ค๋ฅผ ๋ถ™ํ˜€ ๋„ฃ์–ด์ฃผ๋ฉด ์ž๋™์œผ๋กœ
Title Filed์— Email ์ฃผ์†Œ๊ฐ€ ๋“ค์–ด๊ฐ€๋Š” ๊ฑธ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด์š”.

์ด ๋ถ€๋ถ„์€ ์ž„์˜๋กœ ์ˆ˜์ •์ด ๊ฐ€๋Šฅํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ฃผ๋‹ˆ๋Š” ์•„๋ž˜์ฒ˜๋Ÿผ ๋ณ€๊ฒฝํ•ด ์ฃผ์—ˆ์–ด์š”.


๋งŒ๋ฃŒ์ผ์˜ ๊ฒฝ์šฐ ํ•ด๋‹น Key๋ฅผ ์ด์šฉํ•œ ์ ‘์† ๋งŒ๋ฃŒ์ผ์„ ์„ค์ •ํ•ด ์ฃผ๋Š”๊ฑด๋ฐ, ์ฃผ๋‹ˆ๋Š” ๊ณต๋ž€์œผ๋กœ ๋‘์–ด ๋งŒ๋ฃŒ๋˜์ง€ ์•Š๊ฒŒ ํ•ด ์ค„๊ฑฐ์—์š”.

์—ฌ๊ธฐ๊นŒ์ง€ ๋˜์—ˆ๋‹ค๋ฉด ํ‚ค ์ถ”๊ฐ€(Add key)๋ฅผ ๋ˆŒ๋Ÿฌ์ค๋‹ˆ๋‹ค.



์œ„์™€ ๊ฐ™์ด ํ‚ค ๋“ฑ๋ก์„ ์„ฑ๊ณตํ•˜์˜€์–ด์š”.

 

 

 

        ๐Ÿ“ฆ Jenkins Plugin

์ด๋ฒˆ์—๋Š” Jenkins(์  ํ‚จ์Šค)์—์„œ ํ•„์š”ํ•œ Plugin(ํ”Œ๋Ÿฌ๊ทธ์ธ)์„ ์„ค์น˜ํ•ด๋ณด๋„๋ก ํ• ๊ฒŒ์š”.


์œ„์™€ ๊ฐ™์ด ํ”Œ๋Ÿฌ๊ทธ์ธ ํƒญ์œผ๋กœ ์ด๋™ํ•ด ์ค„๊ฒŒ์š”.

๋ฐ˜์‘ํ˜•


์œ„ ์‚ฌ์ง„์ฒ˜๋Ÿผ Git plugins๋ฅผ ์„ค์น˜ํ•ด ์ฃผ์–ด์•ผ ํ•˜๋Š”๋ฐ, ์ฃผ๋‹ˆ๋Š” ์ด๋ฏธ ์„ค์น˜๊ฐ€ ๋˜์–ด ์žˆ์–ด์š”.

 

 


๊ทธ๋ฆฌ๊ณ  gitlab ํ”Œ๋Ÿฌ๊ทธ์ธ๋„ ์„ค์น˜ํ•ด ์ค๋‹ˆ๋‹ค.



ํ”Œ๋Ÿฌ๊ทธ์ธ ์„ค์น˜๊ฐ€ ์™„๋ฃŒ๋˜๋ฉด ์žฌ๊ธฐ๋™์„ ํ•ด์ฃผ์–ด์•ผ ํ•ด์š”.

 

์ด๋Ÿฐ์‹์œผ๋กœ ํ•ด์„œ ์•„๋ž˜ ํ”Œ๋Ÿฌ๊ทธ์ธ๋“ค์„ ์„ค์น˜ํ•ด ์ค„๊ฒŒ์š”.


jenkins lts ์„ค์น˜์‹œ ์„ค์น˜๋˜์–ด ์žˆ๋Š” ํ”Œ๋กœ๊ทธ์ธ: git plugin, Gradle Plugin

์„ค์น˜ ํ•„์š” ํ”Œ๋Ÿฌ๊ทธ์ธ: GitLab, GitLab Brtanch Source Generic Webhook Trigger, Post build task, Docker, Docker Commons, Docker Pipeline, Docker API, SSH Agent, Multibranch Scan Webhook Trigger

 

 

        ๐Ÿ“ฆ GitLab Personal Access Token ๋ฐœ๊ธ‰

Main -> Profile Icon -> ํ™˜๊ฒฝ์„ค์ •


์œ„์™€ ๊ฐ™์ด ํ”„๋กœํ•„ ์•„์ด์ฝ˜์„ ํด๋ฆญํ•˜๊ณ , ํ™˜๊ฒฝ ์„ค์ •์œผ๋กœ ๋“ค์–ด๊ฐ€ ์ค๋‹ˆ๋‹ค.


Access Token(์•ก์„ธ์Šค ํ† ํฐ) -> ์‹ ๊ทœ ํ† ํฐ ์ถ”๊ฐ€


์œ„์™€ ๊ฐ™์ด ์ƒˆ๋กœ์šด ํ† ํฐ์„ ๋ฐœ๊ธ‰ ๋ฐ›์•„ ์ค„๊ฒŒ์š”.



์œ„์™€ ๊ฐ™์ด ํ† ํฐ ์ด๋ฆ„์„ ์ง€์ •ํ•˜๊ณ , ํ•ด๋‹น ํ† ํฐ์˜ ๋งŒ๋ฃŒ์ผ์„ ์ง€์ •ํ•˜๋Š”๋ฐ,
๋งŒ๋ฃŒ์ผ์„ ๋น„์›Œ๋‘๋ฉด ๋งŒ๋ฃŒ๋˜์ง€ ์•Š๊ณ  ๊ณ„์† ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์–ด์š”.

๊ทธ๋ฆฌ๊ณ , ๋ฒ”์œ„ ์„ ํƒ์—์„œ ์‚ฌ์šฉํ•  ์—ญํ• ์— ๋Œ€ํ•ด ์„ ํƒํ•ด ์ค๋‹ˆ๋‹ค.

์—ฌ๊ธฐ๊นŒ์ง€ ๋˜์—ˆ๋‹ค๋ฉด ๊ฐœ์ธ ์•ก์„ธ์Šค ํ† ํฐ ์ƒ์„ฑ์„ ๋ˆŒ๋Ÿฌ ํ† ํฐ์„ ๋งŒ๋“ค์–ด ์ค„ ์ˆ˜ ์žˆ์–ด์š”.



๊ทธ๋Ÿผ ์œ„์™€ ๊ฐ™์ด ํ† ํฐ์ด ์ƒ์„ฑ๋˜๊ณ , ์—ฌ๊ธฐ์„œ Your new ๊ฐœ์ธ ์•ก์„ธ์Šค ํ† ํฐ์„ ๋”ฐ๋กœ ์ ์–ด๋‘๋Š” ๊ฑธ ์ถ”์ฒœ๋“œ๋ ค์š”.


 

 

        ๐Ÿ“ฆ GitLab Project API Token ๋ฐœ๊ธ‰

์ด๋ฒˆ์—๋Š” ๋ฐฐํฌ ๋Œ€์ƒ Project(ํ”„๋กœ์ ํŠธ)์˜ API ํ† ํฐ์„ ๋ฐœ๊ธ‰ ๋ฐ›์•„ ๋ณผ๊ฒŒ์š”.


์ตœ์ดˆ ํ”„๋กœ์ ํŠธ์—์„œ ์œ„์™€ ๊ฐ™์ด ์•ก์„ธ์Šค ํ† ํฐ์œผ๋กœ ์ด๋™ํ•ด ์ค๋‹ˆ๋‹ค.


์œ„์™€ ๊ฐ™์ด ์‹ ๊ทœ ํ† ํฐ ์ถ”๊ฐ€๋ฅผ ๋ˆŒ๋Ÿฌ์ค„๊ฒŒ์š”.



์œ„์™€ ๊ฐ™์ด ํ† ํฐ ์ด๋ฆ„์„ ์„ค์ •ํ•˜๊ณ , ๋งŒ๋ฃŒ์ผ์„ ๊ณต๋ฐฑ์œผ๋กœ ๋‘์–ด ๋งŒ๋ฃŒ๋˜์ง€ ์•Š๊ฒŒ ํ•˜์˜€์–ด์š”.

์—ญํ• ์—๋Š” ํ•ด๋‹น ํ”„๋กœ์ ํŠธ์˜ ํ† ํฐ์„ ํ†ตํ•ด ์ž‘์—…ํ•  ์—ญํ• ์„ ์ง€์ •ํ•ด ์ฃผ์—ˆ๊ณ , ๋ฒ”์œ„๋Š” ๋ชจ๋‘ ์„ ํƒํ•ด ์ฃผ์—ˆ์–ด์š”.
์—ญํ•  ์„ ํƒ์˜ ๊ฒฝ์šฐ ํ•ด๋‹น ํ† ํฐ ์‚ฌ์šฉ์„ ์–ด๋–จ ๋•Œ ํ•˜๋Š๋ƒ์— ๋”ฐ๋ผ ๋‹ฌ๋ผ์งˆ ๊ฒƒ์ด๊ณ ,
๋ฒ”์œ„ ์„ ํƒ์€ ๋˜๋„๋ก ๊ผญ ํ•„์š”ํ•œ ์—ญํ• ๋งŒ ๋ถ€์—ฌํ•˜๋Š” ๊ฑธ ์ถ”์ฒœํ•ด์š”.

์—ฌ๊ธฐ๊นŒ์ง€ ๋˜์—ˆ๋‹ค๋ฉด project access token ์ƒ์„ฑ์„ ๋ˆŒ๋Ÿฌ ํ† ํฐ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.


ํ† ํฐ์˜ ๊ฒฝ์šฐ ๋นจ๊ฐ„ ๋„ค๋ชจ์นธ ํ‘œ์‹œ์˜ ์•„์ด์ฝ˜์„ ๋ˆ„๋ฅด๋ฉด ํด๋ฆฝ๋ณด๋“œ์— ๋ณต์‚ฌ๊ฐ€ ๋ผ์š”.

์ด ํ† ํฐ์„ ์  ํ‚จ์Šค์— ๋“ฑ๋กํ•ด ์ค„๊ฑฐ์—์š”.

 

 

 

 

        ๐Ÿ“ฆ Jenkins Personal Access Token Credentials ์ถ”๊ฐ€

Dashboard -> Jenkins ๊ด€๋ฆฌ -> Credentials


ํ”Œ๋Ÿฌ๊ทธ์ธ ์„ค์น˜๊ฐ€ ์™„๋ฃŒ๋˜๋ฉด ์œ„์™€ ๊ฐ™์ด ์ด๋™ํ•ด ์ค๋‹ˆ๋‹ค.


(global) -> Add credentials


๊ทธ๋ฆฌ๊ณ  ์œ„์™€ ๊ฐ™์ด ์ด๋™ํ•ด ์ค๋‹ˆ๋‹ค.



์ตœ์ดˆ Kind ๋ถ€๋ถ„์„ ์œ„์™€ ๊ฐ™์ด ์„ ํƒํ•ด ์ค„๊ฒŒ์š”.
์ด ๋ถ€๋ถ„์€ gitlab Access Token (์ธ์ฆ ํ† ํฐ)์„ ๋“ฑ๋กํ•˜๋Š” ๊ณณ์ด์—์š”. 



์œ„์™€ ๊ฐ™์ด gitlab ๊ณ„์ • ์ธ์ฆ์šฉ ํ† ํฐ์„ ๋“ฑ๋กํ•ด ์ฃผ์—ˆ์–ด์š”.

 

 

 

 

 

        ๐Ÿ“ฆ Jenkins Project API Token Credentials ์ถ”๊ฐ€

Dashboard -> Jenkins ๊ด€๋ฆฌ -> Credentials -> Global credentials(unrestricted)


์ด๋ฒˆ์—” ํ”„๋กœ์ ํŠธ API ํ† ํฐ ๋“ฑ๋ก์„ ์œ„ํ•ด ๋‹ค์‹œ Credentials ๋“ฑ๋ก์„ ์ง„ํ–‰ํ•ด ๋ณผ๊ฒŒ์š”.



์œ„์™€ ๊ฐ™์ด kind๋ฅผ GitLab API token์œผ๋กœ ์„ ํƒํ•ด ์ค๋‹ˆ๋‹ค.



API token์— gitlab์—์„œ ๋ฐœ๊ธ‰ํ•œ ํ† ํฐ์„ ์ž…๋ ฅํ•ด์ฃผ๊ณ , ID์™€ ์„ค๋ช…์„ ์จ ์ค€ ๋’ค Create๋ฅผ ๋ˆŒ๋Ÿฌ ๋“ฑ๋กํ•ด ์ค„๊ฒŒ์š”.




์ด๋ ‡๊ฒŒ ๋‘ ๊ฐœ์˜ Credentials๊ฐ€ ์  ํ‚จ์Šค์— ๋“ฑ๋ก ๋˜์—ˆ์–ด์š”.

 

 

 

 

 

    ๐Ÿ”ฝ  Jenkins ์„ค์ •

        ๐Ÿ“ฆ GitLab ์—ฐ๋™

์ด๋ฒˆ์—๋Š” ์  ํ‚จ์Šค์—์„œ gitlab ๋“ฑ๋ก์„ ํ•ด์ฃผ๋ ค๊ณ  ํ•ด์š”.

Dashboard -> Jenkins ๊ด€๋ฆฌ -> System


gitlab ๋“ฑ๋ก์„ ์œ„ํ•ด ์œ„์™€ ๊ฐ™์ด System์œผ๋กœ ์ด๋™ํ•ด ์ค„๊ฒŒ์š”.



์Šคํฌ๋กค์„ ๋‚ด๋ฆฌ๋‹ค ๋ณด๋ฉด ์œ„์™€ ๊ฐ™์€ ํ™”๋ฉด์„ ๋งŒ๋‚˜๊ฒŒ ๋ ๊ฑฐ์—์š”.
์ด ๊ณณ์—์„œ ์ž‘์—…ํ•ด ๋ณผ๊ฒŒ์š”.



์ตœ์ดˆ ์œ„์™€ ๊ฐ™์ด ์—ฐ๊ฒฐํ•  gitlab์— ๋Œ€ํ•œ ๊ตฌ๋ถ„์„ ์œ„ํ•ด ์ด๋ฆ„์„ ์ง€์–ด์ฃผ๊ณ , Server URL์— gitlab ์„œ๋ฒ„ ์ฃผ์†Œ๋ฅผ ์ž…๋ ฅํ•ด ์ค๋‹ˆ๋‹ค.
Credentials์—๋Š” gitlab Personal Access Token์— ๋Œ€ํ•œ Credentials๋ฅผ ์„ ํƒํ•ด ์ฃผ๋ฉด ๋ผ์š”.



Web Hook (์›นํ›…)์€ ์ผ๋‹จ ๋ชจ๋‘ ์„ ํƒํ•ด ์ฃผ๊ณ , ์ž์„ธํ•œ ๋‚ด์šฉ์€ ์•„๋ž˜์—์„œ ์ง„ํ–‰ํ•ด ๋ณผ๊ฒŒ์š”.




๊ทธ๋Ÿฐ ๋’ค ์•„๋ž˜์— Test connection์„ ๋ˆŒ๋Ÿฌ ์œ„์™€ ๊ฐ™์ด ๋‚˜์˜ค๋ฉด ์ •์ƒ ์—ฐ๊ฒฐ๋œ ๊ฒƒ์ด์—์š”.


์—ฌ๊ธฐ๊นŒ์ง€ ๋˜์—ˆ๋‹ค๋ฉด ๋งจ ๋ฐ‘์— ์ €์žฅ์„ ๋ˆŒ๋Ÿฌ System ์ฐฝ์„ ๋น ์ ธ ๋‚˜์™€ ์ค๋‹ˆ๋‹ค.

 

 

 

        ๐Ÿ“ฆ Item ๋งŒ๋“ค๊ธฐ

 


์œ„์™€ ๊ฐ™์ด Item์„ ๋งŒ๋“ค์–ด ์ฃผ๋Š”๋ฐ, ์ฃผ๋‹ˆ๋Š” Multibranch Pipeline์œผ๋กœ ๋งŒ๋“ค์–ด ์ค„๊ฑฐ์—์š”.



ํ•ด๋‹น Item ์ด๋ฆ„์„ Display Name์— ์ ์–ด์ฃผ๊ณ , Description์— ์ƒ์„ธ ์„ค๋ช…์„ ์ ์–ด ์ฃผ์—ˆ์–ด์š”.

๊ทธ๋Ÿฐ ๋’ค Branch Sources ์„น์…˜์— Add source ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ์ค๋‹ˆ๋‹ค.



์—ฌ๊ธฐ์„œ GitLab Project๋ฅผ ์„ ํƒํ•ด ์ค„๊ฒŒ์š”.



๊ทธ๋Ÿผ ์œ„์™€ ๊ฐ™์ด ๋‚˜์˜ค๊ฒŒ ๋ ๊ฑฐ์—์š”.

์ข…   ๋ฅ˜ ์ƒ ์„ธ  ๋‚ด ์šฉ
Server ์  ํ‚จ์Šค System์—์„œ ๋“ฑ๋กํ•œ gitlab ์ •๋ณด๊ฐ€ ์ž๋™์œผ๋กœ ํ• ๋‹น.
์—ฌ๋Ÿฌ gitlab ๋“ฑ๋ก ์‹œ ์„ ํƒ ํ•„์š”. 
Checkout
Credentials
Git ์ธ์ฆ์„ ์œ„ํ•œ Username๊ณผ Password ํ˜น์€
gitlab์—์„œ ๋ฐœ๊ธ‰ํ•œ Personal Access Token์— ๋Œ€ํ•œ Credentials ์„ ํƒ.
Owner ํ•ด๋‹น Repository์˜ ์†Œ์œ ์ž ์ •๋ณด ์ž…๋ ฅ.
(๊ฐœ์ธ Repository ์ผ ์‹œ ๊ฐœ์ธ gitlab ID๋ฅผ ๋ช…์‹œํ•˜๊ณ , ์กฐ์ง์œผ๋กœ ์„ค์ •๋˜์–ด ์žˆ๋Š” Repository์˜ ๊ฒฝ์šฐ ์กฐ์ง ์ด๋ฆ„์„ ๋ช…์‹œ) 
Projects ์œ„ 3๊ฐ€์ง€์˜ ์ •๋ณด๊ฐ€ ์ œ๋Œ€๋กœ ์ž…๋ ฅ ๋˜์—ˆ์„ ๊ฒฝ์šฐ ํ•ด๋‹น ์†Œ์œ ์ž์˜ Repository ๋ชฉ๋ก์ด Dropdown ํ˜•์‹์œผ๋กœ ๋ณด์ด๊ฒŒ ๋˜๋ฉฐ,
๋ฐฐํฌ๋ฅผ ์ง„ํ–‰ํ•  Project ์ด๋ฆ„ ์„ ํƒ.




์ด๋ฒˆ์—” ํ•ด๋‹น Item์—์„œ๋งŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” Checkout Credentials๋ฅผ ๋งŒ๋“ค์–ด ๋ณผ๊ฒŒ์š”.


 

์ข…   ๋ฅ˜ ์ƒ ์„ธ  ๋‚ด ์šฉ
Kind Credentials ์ข…๋ฅ˜.
Username GitLab Username (ID).
Password GitLab์—์„œ ๋ฐœ๊ธ‰๋ฐ›์€ Personal Access Token.
ID ํ•ด๋‹น Credentials๋ฅผ ๊ตฌ๋ถ„ํ•œ Unique ๋ฌธ์ž์—ด.
Description ํ•ด๋‹น Credentials์— ๋Œ€ํ•œ ์ƒ์„ธ ์„ค๋ช… ๊ธฐ์žฌ.

์ฃผ๋‹ˆ๋Š” Kind์— Username with password๋ฅผ ์„ ํƒํ•ด ์ฃผ๊ณ  ์ง„ํ–‰ํ•ด ์ฃผ๋ ค๊ณ  ํ•ด์š”.

Add ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ๋“ฑ๋กํ•ด ์ค„๊ฒŒ์š”.



์ƒ์„ฑํ•œ Credentials๋ฅผ ์„ ํƒํ•ด ์ค๋‹ˆ๋‹ค.



ํ˜„์žฌ ์ฃผ๋‹ˆ์˜ ํ”„๋กœ์ ํŠธ๋Š” ์กฐ์ง์œผ๋กœ ์„ค์ • ๋˜์–ด ์žˆ๊ธฐ ๋•Œ๋ฌธ์— gitlab์— ์œ„์˜ ๋นจ๊ฐ„์ƒ‰ ๋„ค๋ชจ์นธ์˜ ํ‘œ์‹œ๋œ ์ •๋ณด์™€ ๊ฐ™์ด ์กฐ์ง ์ •๋ณด๋ฅผ
Owner ๋ถ€๋ถ„์— ๋ช…์‹œํ•ด ์ฃผ์–ด์•ผ ํ•ด์š”.



๊ทธ๋Ÿผ ์œ„์™€ ๊ฐ™์ด Projects์— ์ž๋™์œผ๋กœ ํ”„๋กœ์ ํŠธ ๋ชฉ๋ก์ด ๋ณด์ผํ…๋ฐ, ํ˜„์žฌ ์ฃผ๋‹ˆ๋Š” ํ•œ ๊ฐœ ๋ฐ–์— ์—†์–ด์„œ ๋ฐ”๋กœ ์„ ํƒ ๋˜์—ˆ์–ด์š”.

 


์ด๋ฒˆ์—” Behaviours์— ๋Œ€ํ•ด ์„ค์ •ํ•ด ๋ณด๋„๋ก ํ• ๊ฒŒ์š”.

์ตœ์ดˆ Discover branches๋Š” ํƒ์ƒ‰ํ•  Branch๋ฅผ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋Š” ๋ถ€๋ถ„์ด์—์š”.


์ด ๋ถ€๋ถ„์€ ์œ„์™€ ๊ฐ™์ด ์ด ์„ธ ๊ฐ€์ง€ ์ค‘ ํ•˜๋‚˜๋ฅผ ์„ ํƒํ•  ์ˆ˜ ์žˆ์–ด์š”.

์ข…   ๋ฅ˜ ์ƒ ์„ธ  ๋‚ด ์šฉ
Only branches that are not also field as MRs Merge Request๋กœ ์ œ์ถœ๋˜์ง€ ์•Š์€ Branch๋งŒ ํƒ์ƒ‰.
Only branches that are also field as MRs Merge Request๋กœ ์ œ์ถœ๋œ branch๋งŒ ํƒ์ƒ‰.
All Branches ๋ชจ๋“  Branch ํƒ์ƒ‰.

 

Discover pull requests from forks Strategy


์ฃผ๋‹ˆ๋Š” ๋ชจ๋“  Branch(๋ธŒ๋Ÿฐ์น˜)๋ฅผ ํƒ์ƒ‰ํ•  ์ˆ˜ ์žˆ๋„๋ก All Branches๋ฅผ ์„ ํƒํ•ด ์ค„๊ฑฐ์—์š”.




์ด ๊ณณ์—์„œ๋Š” Pull Request๊ฐ€ ์–ด๋–ป๊ฒŒ ๋ฐœ๊ฒฌ๋˜๋Š”์ง€ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์–ด์š”.

์ข…   ๋ฅ˜ ์ƒ ์„ธ  ๋‚ด ์šฉ
Merging the merge request with
the current target branch revision
ํ˜„์žฌ branch ๋ฒ„์ „๊ณผ ๋ณ‘ํ•ฉ๋œ ์š”์ฒญ์— ๋Œ€ํ•ด ํƒ์ƒ‰.
The current merge request revision ๊ฐ Pull Requtest๋ฅผ ํ•œ ๋ฒˆ์”ฉ ๋ฐœ๊ฒฌํ•˜๊ณ  ๋ณ‘ํ•ฉํ•˜์ง€ ์•Š๊ณ , Pull Requtest Head ๋ฆฌ๋น„์ „์— ํ•ด๋‹นํ•˜๋Š” ๋ฆฌ๋น„์ „ ๊ฒ€์ƒ‰.
Both the current merge request revision and
the merge request merged with
the current target branch revision
ํ˜„์žฌ ๋ณ‘ํ•ฉ ์š”์ฒญ๋œ ๋ฒ„์ „๊ณผ ํ˜„์žฌ branch ์™€ ๋ณ‘ํ•ฉ์š”์ฒญ๋˜์–ด ๋ณ‘ํ•ฉ๋œ ๋ฒ„์ „์— ๋Œ€ํ•ด ํƒ์ƒ‰.


์ด ๊ณณ์—์„œ ์ฃผ๋‹ˆ๋Š” Merging the merge request with the current target branch revision ์‚ฌ์šฉํ•ด ๋ณด๋ ค๊ณ  ํ•ด์š”.



Discover pull requests from forks Trust



Repository์— ๋Œ€ํ•œ ์ฝ๊ธฐ ์•ก์„ธ์Šค ๊ถŒํ•œ์„ ๊ฐ€์ง„ ๋ชจ๋“  ์‚ฌ์šฉ์ž๊ฐ€ Repository๋ฅผ ํฌํฌํ•˜๊ณ ,
์ž์‹ ์˜ ํฌํฌ์— ๋ช‡ ๊ฐ€์ง€ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ์ ์šฉํ•œ ๋‹ค์Œ,
๋ณ€๊ฒฝ ์‚ฌํ•ญ์ด ์žˆ๋Š” ์›๋ž˜ 
Repository์— ๋Œ€ํ•ด Pull Request๋ฅผ ๋งŒ๋“ค ์ˆ˜ ์žˆ์–ด์š”.

์ด ๊ณณ์—๋Š” ์†Œ์Šค ์ฝ”๋“œ ์ œ์–ด์— ์ €์žฅ๋œ ์ค‘์š”ํ•œ ํŒŒ์ผ์ด ์žˆ์„ ๊ฑฐ์—์š”. ์˜ˆ๋ฅผ ๋“ค์–ด Jenkins ํŒŒ์ผ์—๋Š” ์•…์˜์ ์ธ ๊บผ๋‚ด๊ธฐ ์š”์ฒญ์„ ์™„ํ™”ํ•˜๊ธฐ ์œ„ํ•ด ์ƒŒ๋“œ๋ฐ•์Šค ๊บผ๋‚ด๊ธฐ ์š”์ฒญ์— ๋Œ€ํ•œ ๊ตฌ์„ฑ ์„ธ๋ถ€ ์ •๋ณด๊ฐ€ ํฌํ•จ๋  ์ˆ˜ ์žˆ๋‹ต๋‹ˆ๋‹ค. Jenkins ํŒŒ์ผ์„ ์ˆ˜์ •ํ•˜์—ฌ ๋ณดํ˜ธ๋ฅผ ์ œ๊ฑฐํ•˜๋Š” ์•…์˜์ ์ธ ๊บผ๋‚ด๊ธฐ ์š”์ฒญ ์ž์ฒด๋กœ๋ถ€ํ„ฐ ๋ณดํ˜ธํ•˜๊ธฐ ์œ„ํ•ด ํฌํฌ์—์„œ
๊บผ๋‚ด๊ธฐ ์š”์ฒญ์— ๋Œ€ํ•œ ์‹ ๋ขฐ ์ •์ฑ…์„ ์ •์˜ํ•  ์ˆ˜ ์žˆ๋Š” ๋ถ€๋ถ„์ด ์ด ๋ถ€๋ถ„์ด์—์š”.

์ฆ‰, Fork๋œ Repository์— ๋Œ€ํ•ด ๋ณ‘ํ•ฉ ์š”์ฒญ์„ ํƒ์ƒ‰ํ•˜๋Š” ์กฐ๊ฑด์— ๋Œ€ํ•ด ์„ค์ •ํ•ด ์ฃผ๋Š” ๋ถ€๋ถ„์ด์—์š”.

์ข…   ๋ฅ˜ ์ƒ ์„ธ  ๋‚ด ์šฉ
Everyone ๋ชจ๋“  ๊ณณ์— ๋Œ€ํ•ด ์‹ ๋ขฐ.
Members Fork๋œ Repository์˜ Member์ธ ๊ฒฝ์šฐ ์‹ ๋ขฐ.
Nobody Fork๋œ ๊ณณ์—์„œ์˜ ๋ณ‘ํ•ฉ ์š”์ฒญ์€ ๋ชจ๋‘ ๋น„ ์‹ ๋ขฐ.
Trusted Memebers Fork๋œ Repository์—์„œ ์‹ ๋ขฐํ•˜๋Š” Member์ธ ๊ฒฝ์šฐ ์‹ ๋ขฐ.


์ฃผ๋‹ˆ๋Š” ์ด ๊ณณ์—์„œ Trusted Members๋ฅผ ์„ ํƒํ•ด ์ค„๊ฑฐ์—์š”.





์ด๋ฒˆ์—๋Š” Filter by name (with regular expression) ํ™œ์„ฑํ™”๋ฅผ ์œ„ํ•ด ์œ„์™€ ๊ฐ™์ด Add ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ์ค„๊ฑฐ์—์š”.
์ด ๋ถ€๋ถ„์€ Discover์—์„œ ์„ ํƒํ•œ Branch ์ „๋žต ์ค‘ ์ •๊ทœ ํ‘œํ˜„์‹(Regular)๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ CI/CD๋ฅผ ์œ ๋ฐœํ•  Trigger ๋Œ€์ƒ์—
ํฌํ•จํ•  Branch๋ฅผ ๋‹ค์‹œ ์ •ํ•˜๋Š” ๋ถ€๋ถ„์œผ๋กœ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์–ด์š”.


 

์ฃผ๋‹ˆ๋Š” ์œ„์™€ ๊ฐ™์ด ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์šฉ Branch dev์™€ ์šด์˜ ํ™˜๊ฒฝ์šฉ Branch Master๋ฅผ ์„ค์ •ํ•ด ์ค„๊ฑฐ์—์š”.

์ด ๊ณณ์— ์ž…๋ ฅ๋˜์ง€ ์•Š์€ Branch๋Š” CI/CD Trigger๊ฐ€ ๋ฐœ๋™๋˜์ง€ ์•Š์•„์š”.



์ด๋ฒˆ์—๋Š” ์œ„์™€ ๊ฐ™์ด Filter by name (with wildcards)๋ฅผ ํ™œ์„ฑํ™” ํ•ด ์ค„๊ฒŒ์š”.

์ด ๋ถ€๋ถ„์€ Discover ์ „๋žต์— ํ•ด๋‹น๋˜๋Š” Branch ์ค‘ *์œผ๋กœ ๋Œ€์ƒ์— ํฌํ•จํ•  Branch๋ฅผ ๋‹ค์‹œ ์„ ์ •ํ•ด ์ฃผ๋Š” ๊ณณ์ด์—์š”.
Filter by name์€ ํ•˜๋‚˜๋งŒ ์ •ํ•ด์„œ ๊ตฌ์„ฑํ•˜๋Š” ๊ฒƒ์ด ํ˜ผ๋ž€์Šค๋Ÿฝ์ง€ ์•Š์„๊ฑฐ์—์š”.


์ด ๊ณณ๋„ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์šฉ Branch์™€ ์šด์˜ ํ™˜๊ฒฝ์šฉ Branch๋งŒ Trigger๊ฐ€ ๋ฐœ๋™ ๋˜๋„๋ก ์„ค์ •ํ•ด ์ฃผ์—ˆ์–ด์š”.
Exclude์— ํŠน์ • Branch ์ด๋ฆ„์„ ๋„ฃ๊ฒŒ ๋˜๋ฉด ํ•ด๋‹น Branch๋Š” Trigger๊ฐ€ ๋ฐœ๋™๋˜์ง€ ์•Š๊ฒŒ ๋ง‰์„ ์ˆ˜ ์žˆ์–ด์š”.




์ด ๊ณณ Build ์„ค์ • ๋ถ€๋ถ„์€ jenkins File์„ ์ฝ์„ ์ˆ˜ ์žˆ๋„๋ก ์„ค์ •ํ•ด ์ฃผ๋Š” ๋ถ€๋ถ„์ด์—์š”.
์ฃผ๋‹ˆ๋Š” ์†Œ์Šค ์ฝ”๋“œ ๋‚ด์— jenkins File์„ ๋‘˜ ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— ํ•ด๋‹น ์œ„์น˜๋ฅผ ์œ„์™€ ๊ฐ™์ด ์ง€์ •ํ•ด ์ฃผ์—ˆ์–ด์š”.

Scan Multibranch Pipeline Triggers


์ด๋ฒˆ์—” ํ•ด๋‹น Job์„ ํ†ตํ•ด CI/CD๊ฐ€ ๊ฑธ๋ฆด ์ˆ˜ ์žˆ๋Š” Trigger ์„ค์ •์„ ํ•ด ๋ณด๋„๋ก ํ• ๊ฒŒ์š”.

๋‘ ํ•ญ๋ชฉ์„ ๋ชจ๋‘ ํ™œ์„ฑํ™” ์‹œ์ผœ ์ค„๊ฒŒ์š”.

์ตœ์ดˆ pericdically if not otherwise run ์„ค์ •์ด์—์š”.

์ด ์„ค์ •์€ ์ผ๋ถ€ ํด๋” ์œ ํ˜•์€ ์™ธ๋ถ€ ์ด๋ฒคํŠธ๋ฅผ ์ˆ˜์‹ ํ•˜๋Š” ์ฆ‰์‹œ ์ž๋™์œผ๋กœ ๋‹ค์‹œ ์ธ๋ฑ์‹ฑ ๋˜๊ฒŒ ๋˜์š”.
์˜ˆ๋ฅผ ๋“ค์–ด, ๋‹ค์ค‘ ๋ถ„๊ธฐ ํ”„๋กœ์ ํŠธ๋Š” SCM ๋ณ€๊ฒฝ ์•Œ๋ฆผ์„ ์ˆ˜์‹ ํ•  ๋•Œ SCM ์ €์žฅ์†Œ์—์„œ ์ƒˆ ๋ถ„๊ธฐ ๋˜๋Š” ์ œ๊ฑฐ๋˜๊ฑฐ๋‚˜ ์ˆ˜์ •๋œ ๋ถ„๊ธฐ๋ฅผ ๋‹ค์‹œ ํ™•์ธํ•˜๊ฒŒ ๋œ๋‹ต๋‹ˆ๋‹ค. (ํ‘ธ์‹œ ์•Œ๋ฆผ์€ ๊ฐ ๋ถ„๊ธฐ ์†Œ์Šค์— ์‚ฌ์šฉ๋˜๋Š” SCM ํ”Œ๋Ÿฌ๊ทธ์ธ์— ๋”ฐ๋ผ ๊ตฌ์„ฑ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.) ๊ทธ๋Ÿฌ๋‚˜ ์ด๋Ÿฌํ•œ ์•Œ๋ฆผ์€ ๋•Œ๋•Œ๋กœ ์‹ ๋ขฐํ•  ์ˆ˜ ์—†๊ฑฐ๋‚˜ Jenkins๊ฐ€ ์•Œ๋ฆผ์„ ๋ฐ›๊ธฐ ์œ„ํ•ด ์‹คํ–‰ํ•˜์ง€ ์•Š์„ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ์  ํ‚จ์Šค๊ฐ€ ๋ฐฉํ™”๋ฒฝ ๋’ค์— ์žˆ๊ณ  ์™ธ๋ถ€ ์‹œ์Šคํ…œ๋งŒ ํด๋งํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์ฆ‰๊ฐ์ ์ธ ์•Œ๋ฆผ์ด ๋ถˆ๊ฐ€๋Šฅํ•œ ๊ฒฝ์šฐ๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

์ด Trigger๋Š” ํ•„์š”ํ•œ ๊ฒฝ์šฐ ์ฃผ๊ธฐ์ ์ธ ํด๋ฐฑ์„ ํ—ˆ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ง€์ •๋œ ๊ฐ„๊ฒฉ ๋™์•ˆ ์ธ๋ฑ์‹ฑ์ด ์ˆ˜ํ–‰๋˜์ง€ ์•Š์€ ๊ฒฝ์šฐ ์ธ๋ฑ์‹ฑ์ด ์˜ˆ์•ฝ๋ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ๋‹ค์ค‘ ๋ถ„๊ธฐ ํ”„๋กœ์ ํŠธ์˜ ๊ฒฝ์šฐ ํ‘ธ์‹œ ์•Œ๋ฆผ์— ๋Œ€ํ•ด ์†Œ์Šค ์ œ์–ด ์‹œ์Šคํ…œ์ด ๊ตฌ์„ฑ๋˜์–ด ์žˆ์ง€ ์•Š์€ ๊ฒฝ์šฐ ์งง์€ ๊ฐ„๊ฒฉ์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค(๋Œ€๋ถ€๋ถ„์˜ ์‚ฌ์šฉ์ž๊ฐ€ 15๋ถ„์—์„œ 1์‹œ๊ฐ„ ์‚ฌ์ด๋ฅผ ์„ ํƒํ•จ). ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ์œ„ํ•ด ์†Œ์Šค ์ œ์–ด ์‹œ์Šคํ…œ์ด ๊ตฌ์„ฑ๋œ ๊ฒฝ์šฐ ํ‘ธ์‹œ ์•Œ๋ฆผ์ด ์†์‹ค๋œ ๊ฒฝ์šฐ ์ตœ๋Œ€ ํ—ˆ์šฉ ์ง€์—ฐ ์‹œ๊ฐ„์— ํ•ด๋‹นํ•˜๋Š” ๊ฐ„๊ฒฉ์„ ํ•˜๋ฃจ์˜ ๋งˆ์ง€๋ง‰ ์ปค๋ฐ‹์œผ๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. (์ดํ›„ ์ปค๋ฐ‹์€ ์–ด์จŒ๋“  ์ธ๋ฑ์‹ฑ์„ ํŠธ๋ฆฌ๊ฑฐํ•ด์•ผ ํ•˜๊ณ  ์ปค๋ฐ‹์ด ํ”ฝ์—…๋˜๋Š” ๊ฒฐ๊ณผ๋ฅผ ์ดˆ๋ž˜ํ•˜๋ฏ€๋กœ ๋Œ€๋ถ€๋ถ„์˜ ์‚ฌ๋žŒ๋“ค์€ 4์‹œ๊ฐ„์—์„œ 1์ผ ์‚ฌ์ด๋ฅผ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.)

Scan Multibranch Pipeline Triggers -> pericdically if not otherwise run

 

์ด ๊ณณ์—์„œ๋Š” ๋งˆ์ง€๋ง‰ ์ธ๋ฑ์‹ฑ ์ดํ›„ ์ธ๋ฑ์‹ฑ์ด ํŠธ๋ฆฌ๊ฑฐ๋˜๊ธฐ ์ „์— ๊ฒฝ๊ณผํ•  ์ˆ˜ ์žˆ๋Š” ์ตœ๋Œ€ ์‹œ๊ฐ„์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์–ด์š”.
์˜ˆ: ๊ฐ„๊ฒฉ('5m') // ๋˜๋Š” '2h', '7d', '5000ms', '60s'

์ฃผ๋‹ˆ๋Š” ์ด ์„ค์ •์„ 1 day๋กœ ํ•ด ์ค„๊ฒŒ์š”.


Scan Multibranch Pipeline Triggers -> Scan by Webhook


์ด ๊ณณ์€ ๋ฉ€ํ‹ฐ๋ธŒ๋Ÿฐ์น˜ ๊ฒ€์ƒ‰ ์›น ํ›… Trigger๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ 
์ด ๋ฉ€ํ‹ฐ๋ธŒ๋Ÿฐ์น˜ ์ž‘์—…์˜ ๊ฒ€์ƒ‰์„ Triggerํ•  ์ˆ˜ ์žˆ๋„๋ก ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋Š” ๊ณณ์ด์—์š”.

์œ„์™€ ๊ฐ™์ด ?๋ฅผ ๋ˆ„๋ฅด๊ฒŒ ๋˜๋ฉด Payload URL ์˜ˆ์‹œ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด์š”.
ํ† ํฐ์€ ์ž„์˜์˜ ๊ฐ’์„ ๋„ฃ์–ด์ฃผ๊ณ , JENKINS_URL/multibranch-webhook-trigger/invoke?token=[Trigger token] ์„ ๋ฏธ๋ฆฌ ์ž‘์„ฑํ•ด๋†“๊ณ  ์•„๋ž˜์— webhook ์ถ”๊ฐ€ ์‹œ ๋„ฃ์–ด์ฃผ๋ ค๊ณ  ํ•ด์š”.

์ข€ ๋” ์ž์„ธํžˆ ์„ค๋ช…ํ•ด ๋ณด์ž๋ฉด

Trigger token ๋ถ€์— ๋“ค์–ด๊ฐˆ ๋‚ด์šฉ์€ gitlab์—์„œ Webhook ์„ค์ • ์‹œ Request header์— ๋‹ด์„ Webhook Token์„ ์ง€์ •ํ•ด ์ฃผ๋Š” ๋ถ€๋ถ„์ด์—์š”. ์ฆ‰, Webhook Token๊ณผ ์ผ์น˜์‹œํ‚ฌ Token์„ ์„ค์ •ํ•˜๋Š” ๋ถ€๋ถ„์ด์—์š”.
HTTP Request๋กœ JENKINS_URL/multibranch-webhook-trigger/invoke?token=[ํŠธ๋ฆฌ๊ฑฐ ํ† ํฐ]
์œ„์˜ URI๋ฅผ ์ด์šฉํ•ด์„œ Token์ด ์ผ์น˜ํ•˜๋Š” ๊ฒฝ์šฐ ๋‹ค์ค‘ ๋ถ„๊ธฐ ๊ฒ€์ƒ‰์ด bi trigger ๋œ๋‹ต๋‹ˆ๋‹ค.


์ด ๊ณณ์€ ์œ„์—์„œ Gitlab Access Token ์ €์žฅ ์‹œ ์ด์šฉํ–ˆ๋˜ ID ๊ฐ’์„ ์ง€์ •ํ•ด ์ฃผ๋ฉด ๋œ๋‹ต๋‹ˆ๋‹ค.


์ด ๋ถ€๋ถ„ ์„ค์ •์„ ์œ„ํ•ด gitlab์—์„œ ์›นํ›… ์ƒ์„ฑ์„ ํ•ด๋ณด๋ ค๊ณ  ํ•ด์š”.

gitlab -> ํ”„๋กœ์ ํŠธ -> ์„ค์ • -> ์›นํ›…


์œ„์™€ ๊ฐ™์ด ์›นํ›… ์„ค์ •์œผ๋กœ ๋“ค์–ด๊ฐ€ ์ค„๊ฒŒ์š”.



๊ทธ๋ฆฌ๊ณ  ์ƒˆ ์›นํ›… ์ถ”๊ฐ€๋ฅผ ๋ˆŒ๋Ÿฌ ์ค๋‹ˆ๋‹ค.

 

URL์—” ์œ„์—์„œ ๋ฏธ๋ฆฌ ์ž‘์„ฑํ•œ Trigger URL, Secret token์€ Trigger Token์„ ๋„ฃ์–ด์ฃผ์—ˆ์–ด์š”.

๊ทธ๋ฆฌ๊ณ  ์ƒ์„ฑ์„ ๋ˆŒ๋Ÿฌ์ค๋‹ˆ๋‹ค.



๋งŒ์•ฝ ์œ„์™€ ๊ฐ™์€ ๋ฌธ์ œ๊ฐ€ ์ƒ๊ธฐ๋ฉด Local Network(๋กœ์ปฌ ๋„คํŠธ์›Œํฌ)์— ๋Œ€ํ•œ Request(์š”์ฒญ)์ด ํ—ˆ์šฉ๋˜์ง€ ์•Š๋Š”๋‹ค๋Š” ๊ฒƒ์ด์—์š”.

์ด ๋ถ€๋ถ„์„ ํ•ด๊ฒฐํ•ด ๋ณผ๊ฒŒ์š”.

 




์ตœ์ดˆ ๊ด€๋ฆฌ์ž ๊ณ„์ •์œผ๋กœ ๋กœ๊ทธ์ธ ํ•œ ๋’ค ์œ„์™€ ๊ฐ™์ด ๊ด€๋ฆฌ์ž ์˜์—ญ์œผ๋กœ ์ง„์ž…ํ•ฉ๋‹ˆ๋‹ค.


 


๊ทธ๋ฆฌ๊ณ  ์œ„์™€ ๊ฐ™์ด ๋‘ ๊ฐœ๋ฅผ ์ฒดํฌํ•ด ์ฃผ๊ณ , ๋ณ€๊ฒฝ์‚ฌํ•ญ ์ €์žฅ์„ ๋ˆŒ๋Ÿฌ ์ค๋‹ˆ๋‹ค.



๋‹ค์‹œ ์›นํ›…์„ ๋งŒ๋“ค์–ด ์ค„๊ฒŒ์š”.



์›นํ›…์„ ๋งŒ๋“ค๊ณ , ์ž˜ ์„ค์ • ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•ด ๋ณผ ์ˆ˜ ์žˆ์–ด์š”.

Test(ํ…Œ์Šฝ) ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ์—ฌ๋Ÿฌ Event(์ด๋ฒคํŠธ)์— ๋Œ€ํ•ด ํ…Œ์ŠคํŠธ๋ฅผ ํ•ด๋ณผ ์ˆ˜ ์žˆ์–ด์š”.

์ฃผ๋‹ˆ๋Š” ํ‘ธ์‰ฌ ์ด๋ฒคํŠธ ํ…Œ์ŠคํŠธ๋ฅผ ์ง„ํ–‰ํ•ด ๋ณด์•˜๊ณ , ์œ„์™€ ๊ฐ™์ด 200 OK ์‘๋‹ต์„ ๋ฐ›์€๊ฑธ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด์š”.



๋‹ค์‹œ ์  ํ‚จ์Šค๋กœ ๋Œ์•„์™€์„œ
์œ„์™€ ๊ฐ™์ด ์„ค์ •์ด ๋ชจ๋‘ ๋งˆ์ณค์œผ๋ฉด ๋งจ ๋ฐ‘์— Save ํ˜น์€ ์ €์žฅ์„ ๋ˆŒ๋Ÿฌ ํ•ด๋‹น ์„ค์ •์ฐฝ์„ ๋‚˜๊ฐ€๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.

 

 

 

COUPANG

์ฟ ํŒก์€ ๋กœ์ผ“๋ฐฐ์†ก

www.coupang.com

"์ด ํฌ์ŠคํŒ…์€ ์ฟ ํŒก ํŒŒํŠธ๋„ˆ์Šค ํ™œ๋™์˜ ์ผํ™˜์œผ๋กœ, ์ด์— ๋”ฐ๋ฅธ ์ผ์ •์•ก์˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ์ œ๊ณต๋ฐ›์Šต๋‹ˆ๋‹ค."

 

 

 

๐Ÿง ์ฐธ๊ณ  ์ž๋ฃŒ

 

[CI/CD] Jenkins์™€ Gitea ์—ฐ๋™

์  ํ‚จ์Šค ๋งˆ์Šคํ„ฐ COUPANG www.coupang.com "์ด ํฌ์ŠคํŒ…์€ ์ฟ ํŒก ํŒŒํŠธ๋„ˆ์Šค ํ™œ๋™์˜ ์ผํ™˜์œผ๋กœ, ์ด์— ๋”ฐ๋ฅธ ์ผ์ •์•ก์˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ์ œ๊ณต๋ฐ›์Šต๋‹ˆ๋‹ค." ๐Ÿ—‚ ๋ชฉ์ฐจ โš ๏ธ ์•„๋ž˜ ๋ชฉ์ฐจ ์ค‘ ๋ช‡๋ช‡๊ฐœ์˜ ๋งํฌ๊ฐ€ ๊ฑธ๋ฆฌ์ง€ ์•Š๋Š” ๋ฌธ์ œ๋กœ

junyharang.tistory.com

https://giggal-people.tistory.com/entry/CICD-Jenkins-Node-%EC%B6%94%EA%B0%80%ED%95%98%EA%B8%B0

 

 

 

 

 

 

728x90
๋ฐ˜์‘ํ˜•