Jenkins와 Github 연동하기

Soyean·2023년 8월 24일
0

ETC

목록 보기
6/10

Github 설정

1. token 생성

이후 젠킨스에서 credentials을 설정하기 위해 personal access token (classic)이 필요합니다.
https://github.com/settings/tokens/new 진입하여 repo / admin:repo_hook 체크 후 생성합니다.

토큰이 생성된 직후 토큰이 노출되는데 이때 생성된 토큰은 다시 확인할 수 없으니 따로 저장을 해두는 것이 좋습니다.

Jenkins 프로젝스 생성 및 설정

1. Jenkins 실행 ( 설치 방법 )

brew services start jenkins 

http://localhost:8080/ 진입

2. GitHub Servers 추가

Jenkins 관리 > System Configuration : System 진입합니다.
http://localhost:8080/manage/configure

GitHub 영역> [Add GitHub Server] 클릭 후 아래처럼 필드값을 채워줍니다.
-Domain : Global credentials (unrestricted)
-kind : username with password
-scope : Global (Jenkins, nodes, items, all child items, etc)
-username : 깃허브 로그인 ID
-password : 생성한 깃허브 토큰
-ID : 임의로 입력 가능

입력 후 Test connection 클릭 시 아래처럼 문구 노출되면 정상 연결된 것 입니다.

Credentials verified for user id, rate limit: 4999

3. 신규 프로젝트 생성

http://localhost:8080/view/all/newJob > new item 생성

4. 프로젝트 설정

http://localhost:8080/job/Github_Test/configure

▶︎ General
GitHub project > 연동할 깃허브 프로젝트 url 입력
ex : https://github.com/{id}/{projectname}

▶︎ 소스 코드 관리
Git> Repositories> Repository URL> 연동할 깃허브 프로젝트 git 주소 입력 & 하단에서 생성한 credentials 추가
ex : https://github.com/{id}/{projectname}.git

  • credentials 생성
    credentials 하단 ADD 버튼 클릭하여 Add Credentials 페이지 진입합니다.
    시스템 설정 페이지에서 생성한 것과 동일하게 Credentials 정보 입력 후 생성해줍니다.

5. 프로젝트 빌드

프로젝트 페이지 > 지금 빌드 클릭 시 해당 깃허브 빌드됩니다.

참고 : https://www.cybrosys.com/blog/how-to-add-git-credentials-in-jenkins

profile
주니어 QA 🐥

0개의 댓글