簡體   English   中英

如何解決遠程服務器上Jenkins管道語法無法git克隆項目的問題

[英]How to solve the problem that the Jenkins pipeline syntax on the remote server cannot git clone the project

我想在遠程服務器上部署 jenkins,當我將代碼推送到存儲庫時,Jenkins 會自動構建。
我已將 ssh 上傳到 github 並可以使用終端連接。
ssh -T git@github.com
Hi admin, You've successfully authenticated. but GitHub does not provide shell access.
在 jenkins 中,我使用Pipeline script from SCM來監控 git 推送事件。
憑據我選擇使用SSH Username with private key ,並填寫ubuntu遠程服務器的私鑰,但是當我嘗試構建時,出現錯誤。
錯誤信息如下:

Started by user iyao
hudson.plugins.git.GitException: Command "git fetch --tags --force --progress --prune -- origin +refs/heads/iyaomz:refs/remotes/origin/iyaomz" returned status code 128:
stdout: 
stderr: git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2675)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2099)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:85)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:619)
    at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:366)
    at jenkins.scm.api.SCMFileSystem$Builder.build(SCMFileSystem.java:584)
    at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:219)
    at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:191)
    at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:174)
    at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:118)
    at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:70)
    at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:311)
    at hudson.model.ResourceController.execute(ResourceController.java:101)
    at hudson.model.Executor.run(Executor.java:442)
Finished: FAILURE

確保您的憑據包括用戶 Git:

https://issues.jenkins.io/secure/attachment/24768/PrivateKeyConfiguration.png

JENKINS-20879中所述,嘗試使用無密碼的私鑰(未加密創建的私鑰)。

暫無
暫無

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

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