★ 설치 환경 확인
1. 운영환경
$ cat /etc/issue
Ubuntu 22.04 LTS \n \l
2. jenkins 버전
★ 설치 시작
1. jdk 설치
$ sudo apt update
$ sudo apt install openjdk-11-jre
$ java -version
openjdk version "11.0.16" 2022-07-19
OpenJDK Runtime Environment (build 11.0.16+8-post-Ubuntu-0ubuntu122.04)
OpenJDK 64-Bit Server VM (build 11.0.16+8-post-Ubuntu-0ubuntu122.04, mixed mode, sharing)
2. jenkins 패키지 설치
# 설치 및 업그레이드를 자동화하는 Jenkins의 데비안 패키지 저장소입니다.
# 이 저장소를 사용하려면 먼저 시스템에 키를 추가하십시오.
$ curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null
# 그런 다음 Jenkins apt 저장소 항목을 추가합니다.
$ echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
# 로컬 패키지 인덱스를 업데이트한 다음 마지막으로 Jenkins를 설치합니다.
$ sudo apt-get update
$ sudo apt-get install jenkins
3. 실행 (default port : 8080)
http://localhost:8080
# jenkins 최초 실행시 비밀번호를 복사해서 http://localhost:8080에 붙여넣는다
$ cat /var/lib/jenkins/secrets/initialAdminPassword
be6fd6c56af241a08abd2bad2b620418
4. 트러블슈팅
case. install 시 아래와 같은 에러 발생시
● jenkins.service - Jenkins Continuous Integration Server
Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/jenkins.service.d
└─override.conf
Active: activating (auto-restart) (Result: exit-code) since Tue 2022-08-16 02:27:35 EDT; 4ms ago
Process: 1492738 ExecStart=/usr/bin/jenkins (code=exited, status=1/FAILURE)
Main PID: 1492738 (code=exited, status=1/FAILURE)
CPU: 4.886s
dpkg: error processing package jenkins (--configure):
installed jenkins package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
jenkins
E: Sub-process /usr/bin/dpkg returned an error code (1)
default 포트가 이미 리스닝상태라서 발생한 문제로 발생
포트 변경 필요
$ sudo vi /lib/systemd/system/jenkins.service
# Port to listen on for HTTP requests. Set to -1 to disable.
# To be able to listen on privileged ports (port numbers less than 1024),
# add the CAP_NET_BIND_SERVICE capability to the AmbientCapabilities
# directive below.
# 8080 -> 10100 으로 변경하고 저장 후 닫기(esc키 누른후 !wq 엔터)
# Environment="JENKINS_PORT=8080"
Environment="JENKINS_PORT=10100"
$ sudo systemctl restart jenkins.service
Warning: The unit file, source configuration file or drop-ins of jenkins.service
changed on disk. Run 'systemctl daemon-reload' to reload units.
Job for jenkins.service failed because the control process exited with error code.
See "systemctl status jenkins.service" and "journalctl -xeu jenkins.service" for details.
$ systemctl daemon-reload
$ sudo systemctl restart jenkins.service
-> 다시 3번부터 진행
*참조(공식사이트)
'CICD' 카테고리의 다른 글
실제 운영환경에 가까운 nginx.conf 예제 (0) | 2025.04.02 |
---|---|
Nginx 지시자(directive) 기초 분석 예제!! (0) | 2025.04.02 |
왜 dev/prod 환경을 분리해야 할까? (0) | 2025.04.02 |
dockerfile과 docker-compose 비교 와 예제코드 (0) | 2025.04.02 |