簡體   English   中英

Jenkins Github 的發布管道

[英]Jenkins release pipeline for Github

我有一個 Jenkins 管道作業來發布。 它使用 Jenkin 的 Github 插件來檢查項目並進行構建。

我的簡化 DSL 是:

multibranchPipelineJob('Release') {
    ...
    branchSources {
        branchSource {
            source {
                github {
                    id('AAA')
                    repoOwner('BBB')
                    repository('CCC')
                    credentialsId('github-credentials')
                    repositoryUrl('https://github.com/BBB/CCC')
                    configuredByUrl(false)
                }
            }
          ...
        }
    }
    ...
}

我簡化的“Jenkinsfile”就像:

pipeline {
    agent any
    stages {
        stage('Build & Release') {
            steps {
                sh "./gradlew clean build release"
            }
        }
    }
}

但是,當它嘗試執行release任務時,它會失敗並出現以下異常。

Caused by: org.eclipse.jgit.errors.TransportException: https://github.com/BBB/CCC.git: Authentication is required but no CredentialsProvider has been registered
    at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:531)
    at org.eclipse.jgit.transport.TransportHttp.openPush(TransportHttp.java:434)
    at org.eclipse.jgit.transport.PushProcess.execute(PushProcess.java:127)
    at org.eclipse.jgit.transport.Transport.push(Transport.java:1335)
    at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:137)

我的理解是,當release任務運行時,它會嘗試使用 SSH 連接到 Github,但我沒有設置一個,因為我們不想在 Github 上維護 Jenkins 的“用戶”。我如何在不設置的情況下解決這個問題在 Github 上增加 SSH 鍵?

您需要確保在 Jenkins 系統配置頁面中設置了正確的憑據。

文檔中所示,通過Jenkins Credentials 插件注冊存儲在 Jenkins 中的 PAT(個人訪問令牌)。
然后使用 GitHub 插件將其轉換為用戶名/密碼:

Go 到全局配置,添加 GitHub Server Config。

在此處輸入圖像描述

Go 到 Advanced -> Manage Additional GitHub Actions -> Convert Login and Password to token

https://github.com/jenkinsci/github-plugin/blob/master/docs/images/manage-token.png

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM