자습-Jenkins_hello_world
"Hello, World!" 파이프라인 만들기
Jenkins 설치 (Docker로 설치하기)
Jenkins 초기 설정
새로운 파이프라인 Job 생성
파이프라인 스크립트 작성
docker run -d -p 8080:8080 -p 50000:50000 jenkins/jenkins:lts
Jenkins가 http://localhost:8080 에서 실행됨.
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building the project...'
}
}
stage('Test') {
steps {
echo 'Running tests...'
}
}
stage('Deploy') {
steps {
echo 'Deploying the application!'
echo 'Hello, World!'
}
}
}
}
설명:
콘솔 출력(Console Output)에서 아래와 같은 메시지 확인
[Pipeline] Start of Pipeline
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] echo
Building the project...
[Pipeline] }
[Pipeline] stage
[Pipeline] { (Test)
[Pipeline] echo
Running tests...
[Pipeline] }
[Pipeline] stage
[Pipeline] { (Deploy)
[Pipeline] echo
Deploying the application!
[Pipeline] echo
Hello, World!
[Pipeline] }
[Pipeline] End of Pipeline
GitHub 연동
GitHub 저장소 생성 후 Jenkinsfile 추가
Jenkins에서 GitHub 저장소를 연결하여 자동 빌드 설정
pipeline {
agent any
stages {
stage('Clone Repository') {
steps {
git 'https://github.com/ttottonuna/Code_Collection.git'
}
}
stage('Build') {
steps {
echo 'Building from GitHub!'
}
}
}
}
