Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将Jenkins链接到私有Github存储库?_Github_Jenkins - Fatal编程技术网

如何将Jenkins链接到私有Github存储库?

如何将Jenkins链接到私有Github存储库?,github,jenkins,Github,Jenkins,我的目标是将一个私有Github存储库拉到Jenkins 以下是一些背景: 马科斯 Jenkins在本地托管,localhost:8080 在Jenkins中安装了Git插件和Github插件 如果我将存储库公开,詹金斯的一切都很好 在命令行中,我可以用我在Jenkins中使用的相同凭据进行“git克隆”那个私有回购 但当我把它变成私人的,并用它作为詹金斯的来源时,它就坏了 错误是: Building in workspace /Users/Shared/Jenkins/Home/jobs/Te

我的目标是将一个私有Github存储库拉到Jenkins

以下是一些背景:

  • 马科斯
  • Jenkins在本地托管,
    localhost:8080
  • 在Jenkins中安装了Git插件和Github插件
  • 如果我将存储库公开,詹金斯的一切都很好
  • 在命令行中,我可以用我在Jenkins中使用的相同凭据进行“git克隆”那个私有回购
  • 但当我把它变成私人的,并用它作为詹金斯的来源时,它就坏了

    错误是:

    Building in workspace /Users/Shared/Jenkins/Home/jobs/TestFramework/workspace
         > /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
        Fetching changes from the remote Git repository
         > /usr/bin/git config remote.origin.url https://github.com/XXXXXXX/testframework.git # timeout=10
        Fetching upstream changes from https://github.com/XXXXXXX/testframework.git
         > /usr/bin/git --version # timeout=10
        using GIT_ASKPASS to set credentials 
         > /usr/bin/git fetch --tags --progress https://github.com/XXXXXXX/testframework.git +refs/heads/*:refs/remotes/origin/* # timeout=5
        ERROR: Timeout after 5 minutes
        ERROR: Error fetching remote repo 'origin'
        hudson.plugins.git.GitException: Failed to fetch from https://github.com/XXXXXXX/testframework.git
            at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:806)
            at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1070)
            at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1101)
            at hudson.scm.SCM.checkout(SCM.java:496)
            at hudson.model.AbstractProject.checkout(AbstractProject.java:1278)
            at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604)
            at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
            at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
            at hudson.model.Run.execute(Run.java:1728)
            at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
            at hudson.model.ResourceController.execute(ResourceController.java:98)
            at hudson.model.Executor.run(Executor.java:405)
        Caused by: hudson.plugins.git.GitException: Command "/usr/bin/git fetch --tags --progress https://github.com/XXXXXXX/testframework.git +refs/heads/*:refs/remotes/origin/*" returned status code 143:
    
    我在网上尝试了一些建议:

  • ssh-keygen到/Users/shared/jenkins/.ssh/id\u rsa
  • ssh-keygen到/Users/jason/.ssh/id\u rsa
  • 将两个对应的“id_rsa.pub”添加到私有存储库“设置”=>“部署密钥”

  • 但仍然不起作用。

    我想问题可能是:当Jenkins试图克隆回购或获取回购信息时,它将使用一个名为Jenkins的用户名。当然,该用户无权访问您的私人回购协议。如果从命令行执行此操作,您将使用自己的用户名,因此可以成功克隆回购

    您可以通过在项目配置中更改源代码管理的设置来解决此问题

    我们正在做的是为github repo使用“用户名加密码”凭据

  • 输入“存储库URL”后,您可以单击“凭证”旁边的“添加”按钮添加“带密码的用户名”凭证
  • 在弹出窗口中,为“种类”字段选择“用户名和密码”
  • 输入Github帐户的用户名和密码并保存
  • 然后,您可以选择在设置源代码管理时刚刚添加到“凭据”字段中的凭据
  • 希望这能对你有所帮助


    (使用凭据插件添加帐户和密码在某种程度上是安全的,因此您无需担心暴露帐户和密码)

    我用于创建SSH的命令是:SSH keygen。我应该添加一些标签吗?我不确定。thanksI会将这个问题标记为重复,但我看不到这个选项。也许我的名声太低了。无论如何,我想你应该看看这篇文章。这个问题不是你在@user985366上发布的链接的副本。这里的问题是使用git-repo的私有repo的获取标记超时。你评论的问题链接与身份验证和设置有关。我面临这个问题,我已经用凭证插件配置了我的repo,仍然是相同的错误