beaniejoy / dongne-cafe-api

โ˜•๏ธ kotlin & spring boot application (toy project) / siren order service for local cafe
2 stars 1 forks source link

Jenkins Server ๊ตฌ์ถ• ๋‚ด์šฉ #36

Open beaniejoy opened 1 year ago

beaniejoy commented 1 year ago

๐Ÿ“Œ ์  ํ‚จ์Šค ์„œ๋ฒ„ ๊ตฌ์„ฑ


๐Ÿ“Œ ์„ค์น˜

Amazon Linux (CentOS)

==================================================================================================================================
 Package                       Arch                         Version                           Repository                     Size
==================================================================================================================================
Installing:
 jenkins                       noarch                       2.375.3-1.1                       jenkins                        90 M

Transaction Summary
==================================================================================================================================

Ubuntu ์„ค์น˜


๐Ÿ“Œ ์„ค์ •

์‚ฌ์šฉ์ž, ๊ทธ๋ฃน ์ง€์ •

$ sudo vi /etc/sysconfig/jenkins
...
JENKINS_USER="ec2-user"
...

$ sudo vi /usr/lib/systemd/system/jenkins.service 
...
User=ec2-user
Group=ec2-user
...

์  ํ‚จ์Šค์˜ ๋‘ ๊ฐœ์˜ ์„ค์ •ํŒŒ์ผ์—์„œ Amazon Linux2์˜ ์œ ์ €์ธ ec2-user๋กœ ๋ณ€๊ฒฝ

$ chown -R ec2-user:ec2-user /var/lib/jenkins 
$ chown -R ec2-user:ec2-user /var/cache/jenkins
$ chown -R ec2-user:ec2-user /var/log/jenkins

$ sudo systemctl daemon-reload
$ sudo systemctl restart jenkins

๋ฌธ์ œํ•ด๊ฒฐ

  1. ๋กœ๊ทธ์—์„œ ํ•œ๊ธ€๊นจ์ง ๋ฌธ์ œ ์กด์žฌ
    (ํ•ด๊ฒฐ๋ฐฉ๋ฒ• ๋งํฌ)

  2. jenkins ์‹คํ–‰์‹œ java ๋ฌธ์ œ

    jenkins: failed to find a valid Java installation

    ์œ„์™€ ๊ฐ™์€ ๋ฌธ์ œ๋กœ jenkins ์‹คํ–‰์ด ์•ˆ๋˜๋Š”๊ฒฝ์šฐ ์กด์žฌ

    # which java
    /opt/openjdk@17/bin/java
    # ln -s /opt/openjdk@17/bin/java /usr/bin/java
  3. VirtualBox CentOS7 ๋‚ด์— jenkins ์ ‘์†์‹œ ์˜ค๋ฅ˜

    # firewall-cmd --permanent --zone=public --add-port=8080/tcp
    success
    # firewall-cmd --reload
    success

    8080 ํฌํŠธ์— ๋Œ€ํ•œ ๋ฐฉํ™”๋ฒฝ์„ ์˜คํ”ˆํ•ด์•ผ ํ•œ๋‹ค.

  4. AWS Linux 2023์—์„œ ์„ค์น˜

    $ sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key

    https://www.jenkins.io/blog/2023/03/27/repository-signing-keys-changing/ ์ฐธ๊ณ 


๐Ÿ“Œ Jenkins Plugin

ํ•„์š”ํ•œ plugin ์„ค์น˜

ํ•„์š”ํ•œ ์ถ”๊ฐ€ ์„ค์ •

Jenkins ๊ด€๋ฆฌ > System > SSH Server
AWS app-server ๋Œ€์ƒ์ด ๋˜๋Š” instance์— ์ ์šฉ๋œ private key๋ฅผ Jenkins server์— ๊ฐ€์ ธ์™€์•ผ ํ•œ๋‹ค.

$ scp [.pem file] -i [jenkins-server.pem file] ec2-user@[ip_address]:/home/ec2-user/.ssh
beaniejoy commented 1 year ago

Blog ์ž‘์„ฑ