Post

Jenkins 튜토리얼 따라하기 : Guided Tour (1)

Jenkins 튜토리얼 따라하기 : Guided Tour (1)

Jenkins 초기 설정

Jenkins의 password key를 확인하기 위해 다음 명령어를 입력

1
docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword 

아래와 같이 직접 Container에 접속해서 확인할 수도 있다

1
2
docker ps
docker logs <docker-container-name>

image.png

image.png

http://localhost:8080/ 에서 Jenkins UI를 확인할 수 있다

password key를 붙여넣는다

image.png

Install suggested plugins 선택

image.png

image.png

관리자 계정 생성

image.png

Jenkins URL 설정

지금은 별다른 변경 없이 그대로 진행하였다

image.png

설정 완료

image.png

Pipeline 구현

Docker Pipeline plugin 설치

우측 상단의 Manage Jenkins 를 클릭하여 관리 페이지로 간 후, Plugins 클릭

image.png

image.png

Available plugins 클릭 → Docker Pipeline 입력 → Install을 체크하고 설치를 진행한다

image.png

설치 과정이 표시되면 아래로 스크롤해서 Jenkins 재시작 을 선택한다

image.png

image.png

Installed plugins 에서 Docker Pipeline plugin이 설치된 것을 확인할 수 있다

image.png

Repository 설정

repo의 root 경로에 Jenkinsfile 을 생성한다

Jenkinsfile example link : https://www.jenkins.io/doc/pipeline/tour/hello-world/#examples

1
2
3
4
5
6
7
8
9
10
pipeline {
    agent { docker { image 'node:22.14.0-alpine3.21' } }
    stages {
        stage('build') {
            steps {
                sh 'node --version'
            }
        }
    }
}

image.png

Item 추가

Jenkins 에서 New Item을 클릭한다

image.png

적당히 아이템 이름을 입력 한 뒤 Multibranch Pipeline 선택

image.png

Add source 를 누르고 Github 선택

image.png

github repo의 주소 입력후 Validate 를 클릭해서 repo와 연결을 진행한다

이후 Save 를 클릭하면 log에서 repo와 연결 상태를 확인할 수 있다

image.png

image.png

빌드 기록에서 #1 빌드가 성공적으로 수행되었다

로그를 확인하면 node --version 실행 결과를 확인할 수 있다

image.png

image.png

Reference

  1. https://www.jenkins.io/doc/book/installing/docker/
  2. https://www.jenkins.io/doc/pipeline/tour/getting-started/
  3. https://shanepark.tistory.com/500
This post is licensed under CC BY 4.0 by the author.