본문 바로가기

IT

Jenkins 설치

설치 환경

cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

 

공식 가이드 문서는 아래를 참조

https://www.jenkins.io/doc/book/installing/linux/

 

Linux

Jenkins – an open source automation server which enables developers around the world to reliably build, test, and deploy their software

www.jenkins.io

 

최소사양은 아래와 같다.

Minimum hardware requirements:
256 MB of RAM
1 GB of drive space
(although 10 GB is a recommended minimum if running Jenkins as a Docker container)

개발서버 세팅할려고 보니 간당간당한 것도... 같기도 하고... 서버 정보 확인은 이걸로 가능

OS Bit확인
$getconf LONG_BIT

OS 계열확인
$cat /etc/issue

CPU 정보확인
$cat /proc/cpuinfo

메모리 정보확인
$cat /proc/meminfo

DISK 공간확인
$df -h

 

설치는 간편하게 yum을 이용하도록 하자.

설치 순서

1. JAVA 설치

이건 깔려있으니깐 설치정보 확인 

참고로 권장 자바버전은

jdk 8 또는 jdk 11이다.

 

개발서버에는 이렇게 깔려있음.

# yum list installed | grep jdk
copy-jdk-configs.noarch              3.3-10.el7_5                    @base
java-1.8.0-openjdk.x86_64            1:1.8.0.292.b10-1.el7_9         @updates
java-1.8.0-openjdk-devel.x86_64      1:1.8.0.292.b10-1.el7_9         @updates
java-1.8.0-openjdk-headless.x86_64   1:1.8.0.292.b10-1.el7_9         @updates

 

설치는 아래 명령어로 가능하다.

#yum install java-1.8.0-openjdk.x86_64
#yum install java-1.8.0-openjdk-devel.x86_64

설치 후 /etc/profile에 PATH설정을 해준다.

 

# readlink -f $(which javac)
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.292.b10-1.el7_9.x86_64/bin/javac

 

위 명령으로 실제 java home 경로를 알아낸 다음 

 

# Functions and aliases go in /etc/bashrc

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.292.b10-1.el7_9.x86_64
PATH=$PATH:$JAVA_HOME/bin
export PATH
..........
..........
..........

이렇게 path 설정을 해준다.

#source /etc/profile

입력하고 path 설정을 적용시켜준다

 

 

MAVEN 설치

메이븐을 깔아보자.

https://maven.apache.org/download.cgi

 

Maven – Download Apache Maven

Downloading Apache Maven 3.8.1 Apache Maven 3.8.1 is the latest release and recommended version for all users. The currently selected download mirror is https://mirror.navercorp.com/apache/. If you encounter a problem with this mirror, please select anothe

maven.apache.org

위 링크를 열어서 아래 박스 친 링크의 주소를 복사한다.

적당한 위치에 파일을 다운받는다.

#wget https://mirror.navercorp.com/apache/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz

압축을 풀어주고 

# tar xvzf apache-maven-3.8.1-bin.tar.gz

메이븐을 설치할 경로로 디렉터리를 옮기자. tomcat도 저기 밑에 설치되어 있어서 저기다 옮김

mv apache-maven-3.8.1 /usr/local/

마찬가지로 MAVEN_HOME도 /etc/profile에  설정하자.

# Functions and aliases go in /etc/bashrc

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.

export MAVEN_HOME=/usr/local/apache-maven-3.8.1
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.292.b10-1.el7_9.x86_64
PATH=$PATH:$JAVA_HOME/bin
export PATH
..........
..........
..........

 

JENKINS 설치

아래 명령어를 입력해서 jenkins Repo를 추가한다.

 

#wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo
--2021-05-26 23:30:18--  https://pkg.jenkins.io/redhat/jenkins.repo
Resolving pkg.jenkins.io (pkg.jenkins.io)... 151.101.78.133, 2a04:4e42:12::645
Connecting to pkg.jenkins.io (pkg.jenkins.io)|151.101.78.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 71
Saving to: ‘/etc/yum.repos.d/jenkins.repo’

100%[=======================================================>] 71          --.-K/s   in 0s

2021-05-26 23:30:19 (2.93 MB/s) - ‘/etc/yum.repos.d/jenkins.repo’ saved [71/71]

아래 명령어로 rpm에다 퍼블릭 키를 추가시켜준다.

#rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key

yum을 업그레이드해주고, 설치 가능 목록에 jenkins가 추가되어 있는지 확인해보자.

# yum upgrade
# yum list | grep jenkins
hudson.noarch                            1.395-1.1                      jenkins
jenkins.noarch                           2.295-1.1                      jenkins
python2-jenkins.noarch                   0.4.16-2.el7                   epel
python2-jenkins-job-builder.noarch       1.4.0-3.el7                    epel
python36-jenkins.noarch                  0.4.16-2.el7                   epel

위와 같이 뜬다면 제대로 Repo가 추가된 것이다. 

 

# yum install jenkins
# systemctl daemon-reload

위 명령어를 입력하여 설치한다. 이후 데몬을 리로드 시켜주자.

 

Jenkins 환경설정

jenkins 서비스를 시작하기 설정을 진행하자.

/etc/sysconfig/jenkins 파일을 열어 설정한다.

 

1. 유저 설정

yum을 통해 설치하였기 때문에 user 설정은 자동으로 설정되어 있다.(계정 추가 )

JENKINS_USER="jenkins"

변경하고 싶다면 사용자를 추가하고 적용하면 되겠지만, 그냥 사용하자.

 

 

2. 웹 서비스 포트 설정 : 8080 포트는 이미 톰캣에서 사용 중이기 때문에, 9090 포트로 변경한다.

JENKINS_PORT="9090"

설치가 온전하게 되었는지 확인해보자.

# systemctl start jenkins
# systemctl status jenkins
● jenkins.service - LSB: Jenkins Automation Server
   Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
   Active: active (running) since 목 2021-05-27 00:10:11 KST; 3s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 2108 ExecStop=/etc/rc.d/init.d/jenkins stop (code=exited, status=0/SUCCESS)
  Process: 2143 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/jenkins.service
           └─2164 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib...

 5월 27 00:10:11 gcloud-seoul-bed2ebfb0c0857dd7a048030a237fe43 systemd[1]: Starting LSB: Jenkins Automation Server...
 5월 27 00:10:11 gcloud-seoul-bed2ebfb0c0857dd7a048030a237fe43 runuser[2148]: pam_unix(runuser:session): session opened ...0)
 5월 27 00:10:11 gcloud-seoul-bed2ebfb0c0857dd7a048030a237fe43 jenkins[2143]: Starting Jenkins [  OK  ]
 5월 27 00:10:11 gcloud-seoul-bed2ebfb0c0857dd7a048030a237fe43 systemd[1]: Started LSB: Jenkins Automation Server.

잘되네요. 

 

"http://서버 주소:9090"에 접속하면

아래와 같은 창이 뜸.

cat /var/lib/jenkins/secrets/initialAdminPassword

서버에서 /var/lib/jenkins/secrets/initialAdminPassword를 읽어서 초기 비번을 넣어주고 하단의 Continue를 클릭하자(이미지는 잘렸으니 양해를...)

Install suggested plugin을 선택해서 추천 플러그인을 설치하자. 추후 플러그인은 나중에 설치 가능하다. 걱정하지 말자.

.... 왜..... 실패 항목이.....ㅂㄷㅂㄷ

 

Retry가 가능하다... 기다렸다 다시 시도해보자.

짜잔!! 플러그인 설치가 끝나면 사용자 설정 화면이 나온다

계정 정보를 넣어주고 나면 

 

 

설치가 완료되었다!

배포를 위한 설정은 다음에....

'IT' 카테고리의 다른 글

IntelliJ Spring Boot 시작하기  (0) 2021.07.28
Jenkins 설정 (2) - 배포 설정  (0) 2021.05.28
Jenkins 설정 (1) - Global 설정  (0) 2021.05.28