使用 jenkins 克隆私有 repo 时出现问题,错误:克隆远程 repo 'origin' 时出错

时间:2021-03-11 03:52:53

标签: git jenkins github

  1. 我能够克隆公共存储库,但面临使用 jenkins 的私有存储库问题。
  2. 我可以使用命令提示符克隆私有存储库。
  3. 我可以使用 tortoise git 克隆私有存储库。
  4. 但无法使用 jenkins 克隆私有存储库。

Jenkins 版本:

<块引用>

詹金斯 2.263.4

git 路径一定没有问题。我经历过许多类似的问题,但没有一个答案能够解决问题。

Wiping out workspace first.
Cloning the remote Git repository
Cloning repository https://github.com/user/module_name.git
 > C:\Program Files\Git\mingw64\bin\git.exe init C:\Workspace\workspace\Walky # timeout=10
Fetching upstream changes from https://github.com/user/module_name.git
 > C:\Program Files\Git\mingw64\bin\git.exe --version # timeout=10
 > git --version # 'git version 2.30.1.windows.1'
using GIT_ASKPASS to set credentials Vivek git credtials for jenkins Jenkins 
 > C:\Program Files\Git\mingw64\bin\git.exe fetch --tags --force --progress -- https://github.com/user/module_name.git +refs/heads/*:refs/remotes/origin/* # timeout=10
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "C:\Program Files\Git\mingw64\bin\git.exe fetch --tags --force --progress -- https://github.com/user/module_name.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: remote: Repository not found.
fatal: repository 'https://github.com/user/module_name.git/' not found

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2450)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2051)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:84)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:573)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:802)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1221)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1299)
    at hudson.scm.SCM.checkout(SCM.java:505)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1206)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:637)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:509)
    at hudson.model.Run.execute(Run.java:1907)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)
ERROR: Error cloning remote repo 'origin'
Finished: FAILURE

1 个答案:

答案 0 :(得分:1)

首先检查 Jenkins 正在使用哪个帐户运行。

在 Windows 上,它可以 run locally with a LocalSystem 而不是您自己的帐户。

您可以通过一个简单的 bat shell 步骤检查 Jenkins 的工作:

from pyspark.sql.types import StructType, StructField, StringType, ArrayType, MapType

schema = StructType([
    StructField('col1', StringType(), True),
    StructField('col2', ArrayType(
        StructType([
            StructField('id', StringType(), True),
            StructField('metadata', MapType(StringType(), StringType()), True)
        ])
    ))
])

data = [
    ('A', [('id1', {'k': 'v1'}), ('id2', {'k': 'v2', 'k2': 'v5'})]),
    ('B', [('id3', {'k': 'v3'}), ('id4', {'k': 'v4', 'k3': 'v6'})])
]

df = spark.createDataFrame(data=data, schema=schema)

您将看到全局 Git 配置的位置

如果它没有像您一样运行,Jenkins 将无法从必须缓存远程存储库托管服务凭据(用户名/密码)的同一个 Windows 凭据管理器中受益。
这就是为什么您会收到 404 Not Found 的原因。