Jenkins 빌드 서버 설정

참고

작업

  • iam 생성
  • ec2 key pair 생성
  • vpc 생성

create_jenkins_server_vpc_detail

  • 보안 그룹 생성
  • ec2 인스턴스 실행
  • ssh 접속
sudo ssh -i /etc/jenkinsKeyPair.pem ec2-user@ec2-3-34-53-35.ap-northeast-2.compute.amazonaws.com
  • 젠킨스 설치
$ sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
--2024-01-03 14:37:35--  http://pkg.jenkins-ci.org/redhat/jenkins.repo
Resolving pkg.jenkins-ci.org (pkg.jenkins-ci.org)... 52.202.51.185
Connecting to pkg.jenkins-ci.org (pkg.jenkins-ci.org)|52.202.51.185|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://pkg.jenkins.io/redhat/jenkins.repo [following]
--2024-01-03 14:37:35--  https://pkg.jenkins.io/redhat/jenkins.repo
Resolving pkg.jenkins.io (pkg.jenkins.io)... 146.75.50.133, 2a04:4e42:7c::645
Connecting to pkg.jenkins.io (pkg.jenkins.io)|146.75.50.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 71
Saving to: /etc/yum.repos.d/jenkins.repo

/etc/yum.repos.d/jenkins.repo                100%[============================================================================================>]      71  --.-KB/s    in 0s      

2024-01-03 14:37:35 (2.63 MB/s) - /etc/yum.repos.d/jenkins.repo saved [71/71]

$ sudo rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key
$ sudo yum install jenkins -y
Jenkins                                                                                                                                            89 kB/s | 113 kB     00:01    
Dependencies resolved.
==================================================================================================================================================================================
 Package                                   Architecture                             Version                                       Repository                                 Size
==================================================================================================================================================================================
Installing:
 jenkins                                   noarch                                   2.439-1.1                                     jenkins                                    82 M

Transaction Summary
==================================================================================================================================================================================
Install  1 Package

Total download size: 82 M
Installed size: 82 M
Downloading Packages:
jenkins-2.439-1.1.noarch.rpm                                                                                                                      8.6 MB/s |  82 MB     00:09    
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                             8.6 MB/s |  82 MB     00:09     
Public key for jenkins-2.439-1.1.noarch.rpm is not installed
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'yum clean packages'.
Error: GPG check FAILED

# 에러발생
# https://kodekloud.com/community/t/unable-to-install-jenkins-server-gpg-key-error/341268
# https://www.jenkins.io/doc/book/installing/linux/#red-hat-centos 참고

[ec2-user@ip-10-0-1-115 ~]$ sudo wget -O /etc/yum.repos.d/jenkins.repo \
    https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
sudo yum upgrade
--2024-01-03 14:59:30--  https://pkg.jenkins.io/redhat-stable/jenkins.repo
Resolving pkg.jenkins.io (pkg.jenkins.io)... 146.75.50.133, 2a04:4e42:7c::645
Connecting to pkg.jenkins.io (pkg.jenkins.io)|146.75.50.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 85
Saving to: /etc/yum.repos.d/jenkins.repo

/etc/yum.repos.d/jenkins.repo                       100%[=================================================================================================================>]      85  --.-KB/s    in 0s      

2024-01-03 14:59:30 (5.29 MB/s) - /etc/yum.repos.d/jenkins.repo saved [85/85]

Jenkins-stable                                                                                                                                                                 30 kB/s |  28 kB     00:00    
Dependencies resolved.
Nothing to do.
Complete!

$ sudo yum install jenkins
Last metadata expiration check: 0:02:36 ago on Wed Jan  3 14:59:32 2024.
Dependencies resolved.
==============================================================================================================================================================================================================
 Package                                          Architecture                                    Version                                              Repository                                        Size
==============================================================================================================================================================================================================
Installing:
 jenkins                                          noarch                                          2.426.2-1.1                                          jenkins                                           85 M

Transaction Summary
==============================================================================================================================================================================================================
Install  1 Package

Total download size: 85 M
Installed size: 85 M
Is this ok [y/N]: y
Downloading Packages:
jenkins-2.426.2-1.1.noarch.rpm                                                                                                                                                 10 MB/s |  85 MB     00:08    
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                          10 MB/s |  85 MB     00:08     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                      1/1 
  Running scriptlet: jenkins-2.426.2-1.1.noarch                                                                                                                                                           1/1 
  Installing       : jenkins-2.426.2-1.1.noarch                                                                                                                                                           1/1 
  Running scriptlet: jenkins-2.426.2-1.1.noarch                                                                                                                                                           1/1 
  Verifying        : jenkins-2.426.2-1.1.noarch                                                                                                                                                           1/1 

Installed:
  jenkins-2.426.2-1.1.noarch                                                                                                                                                                                  

Complete!

# 에러 발생

$ sudo yum install java-17-openjdk
Last metadata expiration check: 1 day, 10:10:47 ago on Wed Jan  3 14:59:32 2024.
No match for argument: java-17-openjdk
Error: Unable to find a match: java-17-openjdk

$ yum search java | grep development
Last metadata expiration check: 0:16:59 ago on Fri Jan  5 01:10:53 2024.
openmpi-java-devel.x86_64 : Java development files for openmpi
java-1.8.0-amazon-corretto-devel.x86_64 : Amazon Corretto development environment
java-11-amazon-corretto.x86_64 : Amazon Corretto development environment
java-11-amazon-corretto-devel.x86_64 : Amazon Corretto 11 development tools
java-11-amazon-corretto-headless.x86_64 : Amazon Corretto headless development environment
java-17-amazon-corretto.x86_64 : Amazon Corretto development environment
java-17-amazon-corretto-devel.x86_64 : Amazon Corretto 17 development tools
java-17-amazon-corretto-headless.x86_64 : Amazon Corretto headless development environment
java-21-amazon-corretto.x86_64 : Amazon Corretto development environment
java-21-amazon-corretto-devel.x86_64 : Amazon Corretto 21 development tools
java-21-amazon-corretto-headless.x86_64 : Amazon Corretto headless development environment
R-core-devel.x86_64 : Core files for development of R packages (no Java)
nodejs-devel.x86_64 : JavaScript runtime - development headers
nodejs20-devel.x86_64 : JavaScript runtime - development headers

$ sudo yum install java-17-amazon-corretto-devel
Last metadata expiration check: 1 day, 10:29:28 ago on Wed Jan  3 14:59:32 2024.
Dependencies resolved.
============================================================================================================================
 Package                                    Architecture     Version                            Repository             Size
============================================================================================================================
Installing:
 java-17-amazon-corretto-devel              x86_64           1:17.0.9+8-1.amzn2023.1            amazonlinux           149 k
Installing dependencies:
 alsa-lib                                   x86_64           1.2.7.2-1.amzn2023.0.2             amazonlinux           504 k
 dejavu-sans-fonts                          noarch           2.37-16.amzn2023.0.2               amazonlinux           1.3 M
 dejavu-sans-mono-fonts                     noarch           2.37-16.amzn2023.0.2               amazonlinux           467 k
 dejavu-serif-fonts                         noarch           2.37-16.amzn2023.0.2               amazonlinux           1.0 M
 java-17-amazon-corretto-headless           x86_64           1:17.0.9+8-1.amzn2023.1            amazonlinux            91 M
 javapackages-filesystem                    noarch           6.0.0-7.amzn2023.0.6               amazonlinux            12 k
 libjpeg-turbo                              x86_64           2.1.4-2.amzn2023.0.5               amazonlinux           190 k

Transaction Summary
============================================================================================================================
Install  8 Packages

Total download size: 95 M
Installed size: 249 M
Is this ok [y/N]: y
Downloading Packages:
(1/8): libjpeg-turbo-2.1.4-2.amzn2023.0.5.x86_64.rpm                                        2.8 MB/s | 190 kB     00:00    
(2/8): alsa-lib-1.2.7.2-1.amzn2023.0.2.x86_64.rpm                                           6.5 MB/s | 504 kB     00:00    
(3/8): dejavu-serif-fonts-2.37-16.amzn2023.0.2.noarch.rpm                                    20 MB/s | 1.0 MB     00:00    
(4/8): java-17-amazon-corretto-devel-17.0.9+8-1.amzn2023.1.x86_64.rpm                       1.8 MB/s | 149 kB     00:00    
(5/8): dejavu-sans-fonts-2.37-16.amzn2023.0.2.noarch.rpm                                     25 MB/s | 1.3 MB     00:00    
(6/8): dejavu-sans-mono-fonts-2.37-16.amzn2023.0.2.noarch.rpm                               8.8 MB/s | 467 kB     00:00    
(7/8): javapackages-filesystem-6.0.0-7.amzn2023.0.6.noarch.rpm                              520 kB/s |  12 kB     00:00    
(8/8): java-17-amazon-corretto-headless-17.0.9+8-1.amzn2023.1.x86_64.rpm                     47 MB/s |  91 MB     00:01    
----------------------------------------------------------------------------------------------------------------------------
Total                                                                                        47 MB/s |  95 MB     00:02     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                    1/1 
  Installing       : dejavu-sans-mono-fonts-2.37-16.amzn2023.0.2.noarch                                                 1/8 
  Installing       : dejavu-sans-fonts-2.37-16.amzn2023.0.2.noarch                                                      2/8 
  Installing       : javapackages-filesystem-6.0.0-7.amzn2023.0.6.noarch                                                3/8 
  Installing       : dejavu-serif-fonts-2.37-16.amzn2023.0.2.noarch                                                     4/8 
  Installing       : libjpeg-turbo-2.1.4-2.amzn2023.0.5.x86_64                                                          5/8 
  Installing       : alsa-lib-1.2.7.2-1.amzn2023.0.2.x86_64                                                             6/8 
  Installing       : java-17-amazon-corretto-headless-1:17.0.9+8-1.amzn2023.1.x86_64                                    7/8 
  Running scriptlet: java-17-amazon-corretto-headless-1:17.0.9+8-1.amzn2023.1.x86_64                                    7/8 
  Installing       : java-17-amazon-corretto-devel-1:17.0.9+8-1.amzn2023.1.x86_64                                       8/8 
  Running scriptlet: java-17-amazon-corretto-devel-1:17.0.9+8-1.amzn2023.1.x86_64                                       8/8 
  Verifying        : alsa-lib-1.2.7.2-1.amzn2023.0.2.x86_64                                                             1/8 
  Verifying        : libjpeg-turbo-2.1.4-2.amzn2023.0.5.x86_64                                                          2/8 
  Verifying        : java-17-amazon-corretto-headless-1:17.0.9+8-1.amzn2023.1.x86_64                                    3/8 
  Verifying        : java-17-amazon-corretto-devel-1:17.0.9+8-1.amzn2023.1.x86_64                                       4/8 
  Verifying        : dejavu-serif-fonts-2.37-16.amzn2023.0.2.noarch                                                     5/8 
  Verifying        : dejavu-sans-fonts-2.37-16.amzn2023.0.2.noarch                                                      6/8 
  Verifying        : dejavu-sans-mono-fonts-2.37-16.amzn2023.0.2.noarch                                                 7/8 
  Verifying        : javapackages-filesystem-6.0.0-7.amzn2023.0.6.noarch                                                8/8 

Installed:
  alsa-lib-1.2.7.2-1.amzn2023.0.2.x86_64                                                                                    
  dejavu-sans-fonts-2.37-16.amzn2023.0.2.noarch                                                                             
  dejavu-sans-mono-fonts-2.37-16.amzn2023.0.2.noarch                                                                        
  dejavu-serif-fonts-2.37-16.amzn2023.0.2.noarch                                                                            
  java-17-amazon-corretto-devel-1:17.0.9+8-1.amzn2023.1.x86_64                                                              
  java-17-amazon-corretto-headless-1:17.0.9+8-1.amzn2023.1.x86_64                                                           
  javapackages-filesystem-6.0.0-7.amzn2023.0.6.noarch                                                                       
  libjpeg-turbo-2.1.4-2.amzn2023.0.5.x86_64                                                                                 

Complete!

$ java --version
openjdk 17.0.9 2023-10-17 LTS
OpenJDK Runtime Environment Corretto-17.0.9.8.1 (build 17.0.9+8-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.9.8.1 (build 17.0.9+8-LTS, mixed mode, sharing)

$ sudo systemctl status jenkins
 jenkins.service - Jenkins Continuous Integration Server
     Loaded: loaded (/usr/lib/systemd/system/jenkins.service; enabled; preset: disabled)
     Active: active (running) since Fri 2024-01-05 01:30:55 UTC; 1min 15s ago
   Main PID: 86820 (java)
      Tasks: 39 (limit: 1114)
     Memory: 366.5M
        CPU: 38.665s
     CGroup: /system.slice/jenkins.service
             └─86820 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jenkins/w>

Jan 05 01:30:24 ip-10-0-1-115.ap-northeast-2.compute.internal jenkins[86820]: 84550e16035847cc8c9c4e35950c5f2d
Jan 05 01:30:24 ip-10-0-1-115.ap-northeast-2.compute.internal jenkins[86820]: This may also be found at: /var/lib/jenkins/s>
Jan 05 01:30:24 ip-10-0-1-115.ap-northeast-2.compute.internal jenkins[86820]: *********************************************>
Jan 05 01:30:24 ip-10-0-1-115.ap-northeast-2.compute.internal jenkins[86820]: *********************************************>
Jan 05 01:30:24 ip-10-0-1-115.ap-northeast-2.compute.internal jenkins[86820]: *********************************************>
Jan 05 01:30:55 ip-10-0-1-115.ap-northeast-2.compute.internal jenkins[86820]: 2024-01-05 01:30:55.506+0000 [id=32]        I>
Jan 05 01:30:55 ip-10-0-1-115.ap-northeast-2.compute.internal jenkins[86820]: 2024-01-05 01:30:55.531+0000 [id=24]        I>
Jan 05 01:30:55 ip-10-0-1-115.ap-northeast-2.compute.internal systemd[1]: Started jenkins.service - Jenkins Continuous Inte>
Jan 05 01:30:56 ip-10-0-1-115.ap-northeast-2.compute.internal jenkins[86820]: 2024-01-05 01:30:56.383+0000 [id=47]        I>
Jan 05 01:30:56 ip-10-0-1-115.ap-northeast-2.compute.internal jenkins[86820]: 2024-01-05 01:30:56.386+0000 [id=47]        I>
lines 1-20/20 (END)
  • http://ec2-3-34-53-35.ap-northeast-2.compute.amazonaws.com:8080 접속

create_jenkins_server_jenkins_login

  • 패스워드 검색
$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword

links

social