Github 연결
id/pw
-
'Credentials' > 'System' > 'Global credentials' > 'Add Credentials' 이동
-
Kind에 'Username with password’로 추가
-
'Manage Jenkins' > 'Configure System' 에서 Github 까지 이동
-
여기서 가장 아래에 '고급' 선택 후 'Additional action’에 'Convert login and password to token' 선택
-
'Create token credentials' 를 클릭하면 github과 jenkins에 자동으로 추가됨
-
다시 'Manage Jenkins' > 'Configure System' 에서 Github 까지 이동 후 위에서 추가한 token 인증으로 설정
-
git repository에 jenkins에서 접근 하는 계정의 권한을 추가('Setting' > 'Collaborators & teams')
ssh
-
Jenkins에 Github integration plugin 설치
-
서버에서 sshkey 생성
-
pub 키를 github에 추가 (Settings → Deploy keys)
-
private 키는 jenkins에 추가(Add Credentials → Kind: SSH Username with private key)
-
Username: job에서 보여줄 인증키
-
-
Create new item
-
Add repository URL:
git@github.com:user/repo.git
-
-
webhook 추가(Settings → Hooks)
-
Payload URL:
<jenkins url>/github-webhook/
마지막에 슬래쉬 붙여줘야 함 → https://stackoverflow.com/a/49118822/3793078
-
pr hook
-
Jenkins에 Github Pull Request Builder 플러그인 설치
-
Jenkins 설정에서 플러그인 각종 설정 추가
-
Github에 repo의 Setting - Hooks에
jenkins-url/ghprbhook/
등록할 것
(github-webhook/
은GitHub hook trigger for GITScm polling
설정임)
New Item (pipeline)
-
Jenkins → 'New Item'
-
Select 'Pipeline'
-
'Build Triggers'
-
Check 'GitHub hook trigger for GITScm polling'
-
-
'Pipeline'
-
Definition: Pipeline script from SCM
-
SCM: Git
-
-
-
Job을 한번 실행시켜줘야 다음부터 hook을 받음