
Run service as LocalSystem 선택18080 사용브라우저에서 http://localhost:18080 접속
안내된 경로의 파일에서 초기 관리자 비밀번호 확인 후 입력
추천 플러그인 설치 모드로 진행
Admin User 생성
swcampswcampJenkins URL 확인 후 종료
Jenkins 관리 > Plugins > Available pluginslocale 검색 후 설치http://localhost:18080/restartPipeline: Stage View 설치Publish Over SSH 설치경로: Jenkins 관리 > Tools > JDK installations
Add JDK
openJDK21Jenkins 관리 > Tools > Gradle installationsAdd GradleInstall automatically 선택# 디렉토리 생성/이동
mkdir ./ssh-jenkins
cd ./ssh-jenkins
# .ssh 디렉토리 생성
mkdir ./.ssh
# SSH 인증키 생성 (비밀번호 10자 이상 권장)
ssh-keygen -t rsa -f .ssh/ssh-jenkins-github--key
# 키 확인
cd ./.ssh
cat ssh-jenkins-github--key # private key
cat ssh-jenkins-github--key.pub # public key
SSH: 원격 접속/명령 실행/파일 전송을 위한 암호화 프로토콜
RSA 키 쌍
security:
gitHostKeyVerificationConfiguration:
sshHostKeyVerificationStrategy:
manuallyProvidedKeyVerificationStrategy:
approvedHostKeys: |-
github.com ssh-rsa A0000AAAB3NzaC1yc2EAAAADAQABAAABgQ...
경로: Jenkins 관리 > Credentials
Domains 하단 화살표 → Add credentials
Kind: SSH Username with private key
ID: SSH 키 식별자(파이프라인에서 참조할 값)
Username: 예) my-github-key
Private Key: Enter directly 선택 후 private key 붙여넣기
Passphrase: 키 생성 시 입력한 비밀번호
Username with passwordDOCKERHUB_PASSWORDFROM eclipse-temurin:21-jdk-alpine
WORKDIR /app
COPY build/libs/*.jar app.jar
ENTRYPOINT ["java", "-jar", "app.jar"]
git init
git remote add origin <github remote repo 주소>
git add *
git commit -m "commit message"
git push origin main
다운로드(Windows 64bit): https://ngrok.com/download
ngrok config add-authtoken $YOUR_AUTHTOKEN
ngrok http 18080
GitHub repository > Settings > Deploy keys > Add deploy keyssh-jenkins-github--key.pub) 등록GitHub repository > Settings > Webhooks > Add webhook/github-webhook/ 추가예시
https://<ngrok-domain>/github-webhook/Jenkins > 새로운 ItemPipeline 선택 → OKGitHub Project 체크Build TriggersGitHub hook trigger for GITScm polling 체크동작 흐름
GITHUB_URL은 repo에 맞게 변경
이미지명 test-pipe도 필요하면 변경
pipeline {
agent any
tools {
gradle 'gradle'
jdk 'openJDK21'
}
environment {
DOCKERHUB_CREDENTIALS = credentials('DOCKERHUB_PASSWORD')
GITHUB_URL = 'https://github.com/{url}'
}
stages {
stage('Preparation') {
steps {
script {
if (isUnix()) {
sh 'docker --version'
} else {
bat 'docker --version'
}
}
}
}
stage('Source Build') {
steps {
git branch: 'main', url: "${env.GITHUB_URL}"
script {
if (isUnix()) {
sh "chmod +x ./gradlew"
sh "./gradlew clean build"
} else {
bat "gradlew.bat clean build"
}
}
}
}
stage('Container Build and Push') {
steps {
script {
withCredentials([usernamePassword(credentialsId: 'DOCKERHUB_PASSWORD', usernameVariable: 'DOCKER_USER', passwordVariable: 'DOCKER_PASS')]) {
if (isUnix()) {
sh "docker build -t ${DOCKER_USER}/test-pipe:latest ."
sh "docker login -u ${DOCKER_USER} -p ${DOCKER_PASS}"
sh "docker push ${DOCKER_USER}/test-pipe:latest"
} else {
bat "docker build -t ${DOCKER_USER}/test-pipe:latest ."
bat "docker login -u %DOCKER_USER% -p %DOCKER_PASS%"
bat "docker push ${DOCKER_USER}/test-pipe:latest"
}
}
}
}
}
}
post {
always {
script {
if (isUnix()) {
sh 'docker logout'
} else {
bat 'docker logout'
}
}
}
success {
echo 'Pipeline succeeded!'
}
failure {
echo 'Pipeline failed!'
}
}
}
지금 빌드로 수동 실행 1회 필요.../github-webhook/로 설정