[GitHub Guide](https://github.com/jenkinsci/github-branch-source-plugin/blob/master/docs/github-app.adoc) 一.使用Github App Jenkins Plugin訪問Github 1.設定Github `Settings/Developer Settings/GitHub Apps` => New GitHub App 只有這兩個值必填 Github App name, Homepage URL 產生private key => Generate a private key 將private key格式從pkcs1轉換成pkcs8 [下載openssl](https://www.openssl.org/source/),使用命令提示字元進行轉換 產生完成GithubApp後選擇左邊InstallApp, 安裝完成後,Applications選擇repositories access權限 2.建立Jenkins Credentials `管理Jenkins/Credentials/System/Global credentials` 將Github App產生的資料帶入, 填入openssl轉換後的pkcs8格式的private key [參考](https://blog.csdn.net/a7442358/article/details/127888512) 3.使用建立好的Credentials進行git同步 `git branch: 'main', credentialsId: 'GaiaGitHub', url:'https://github.com/CannonUFO/Gaia.git'` script區塊用來執行Groovy語法 checkout = Jenkins Git Plugin提供語法,執行Git相關操作 ``` stage('Source') { steps{ script { checkout([$class: 'GitSCM', branches: [[name: 'main']], userRemoteConfigs: [[url:'https://github.com/CannonUFO/Gaia.git', credentialsId: 'GaiaGitHub']], extensions: [[$class: 'CloneOption', shallow: true], [$class: 'RelativeTargetDirectory',relativeTargetDir: 'Dev']], poll: true]) } } } ``` [groovy語法](https://wiki.eryajf.net/pages/3298.html#_6-when) [Jenkinsfile同使存取多個Git庫](https://www.cnblogs.com/fengyinxu/p/jenkins-parallel-checkout-multiple-git-repositories.html) [Jenkins程式碼打包](https://juejin.cn/post/7228855520566919227) 3.Webhook [GitHub Webhook](https://plugins.jenkins.io/github/) [GitHub Webhook](https://hevodata.com/learn/jenkins-github-webhook/) todo:目前使用外部私人GitHub連線被擋,等換公司GitHub再試 二.[GitHub Authentication](https://plugins.jenkins.io/github-oauth/) 使用Github訪問Jenkins 設定Github Settings/Developer Settings/OAuth Apps => new OAuth App 只有Client ID、ClientSecrets有用 Jenkins設定 管理Jenkins/Security/Authentication/安全性領域
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up