practice trigger project build on jenkins with github
- github → jenkins
- Flow : commit code to github → jenkins build → return build result to github
- Git project : https://github.com/alexho0205/practice_jenkins_build
- Steps
- create personal token on github ( settings → developer settings )
- add github server on jenkins ( system → github servers )
- put personal token to credential ( credential type = secret text )
- create ssh-key pair
- put public key on github ( profile → settings → ssh and GPG keys → add ssh keys )
- put private key on jenkins ( credentials → add credentials → ssh with private key )
- add webhook on github (
- url →
${jenkins_url}
/github-webhoook/ - content type → json
- url →
- create free-style job (jenkins)
- trigger jenkins to build project : commit code directly (github)
- check build result on github : repo -> commits -> green check (綠色小勾勾)
- Bug Fix
- 如果 jenkins 是全新的,第一次連線 github.com 前,需要加入 host key
-
( linux )ssh 登入到 jenkins ,切換身份到 jenkins
# 切換身份 $ sudo su jenkins # 連線github.com,請自行變更 repo 位置 # 連線後,linux 發現沒有 github.com 的 host key # 尋問是否加入 -> YES $ git ls-remote -h -- [email protected]:alexho0205/practice_jenkins_build.git HEAD
-
- jenkins 需要外部IP,可使用ngrok
- 如果 jenkins 是全新的,第一次連線 github.com 前,需要加入 host key