当前位置: 首页 > 面试题库 >

带有https的Jenkins Git插件

江天宇
2023-03-14
问题内容

我正在尝试使用Git插件在Jenkins中配置Git项目。在项目配置页面中,我在Git配置中输入存储库URL,这是一个https
URL(https://git.mycompany.com/git/MyProject.git)。但是,在构建项目时,出现以下错误:

Started by user Hudson Administrator
[EnvInject] - Loading node environment variables.
Building in workspace /home/hudson/.hudson/jobs/MyProject/workspace
Checkout:workspace / /home/hudson/.hudson/jobs/MyProject/workspace - hudson.remoting.LocalChannel@3699cfcc
Using strategy: Default
Cloning the remote Git repository
Cloning repository https://git.mycompany.com/git/MyProject.git
git --version
git version 1.8.2.1
ERROR: Error cloning remote repo 'origin' : Could not clone https://git.mycompany.com/git/MyProject.git
hudson.plugins.git.GitException: Could not clone https://git.mycompany.com/git/MyProject.git
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:286)
    at org.jenkinsci.plugins.gitclient.AbstractGitAPIImpl.clone(AbstractGitAPIImpl.java:59)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.clone(CliGitAPIImpl.java:47)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1012)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:948)
    at hudson.FilePath.act(FilePath.java:912)
    at hudson.FilePath.act(FilePath.java:885)
    at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:948)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1114)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1411)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:652)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:557)
    at hudson.model.Run.execute(Run.java:1665)
    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:507)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:230)
Caused by: hudson.plugins.git.GitException: Failed to connect to https://git.mycompany.com/git/MyProject.git
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.getURLWithCrendentials(CliGitAPIImpl.java:1374)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.getURLWithCrendentials(CliGitAPIImpl.java:1326)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:47)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:280)
    ... 16 more
Trying next repository
ERROR: Could not clone repository
java.io.IOException: Could not clone
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1025)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:948)
    at hudson.FilePath.act(FilePath.java:912)
    at hudson.FilePath.act(FilePath.java:885)
    at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:948)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1114)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1411)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:652)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:557)
    at hudson.model.Run.execute(Run.java:1665)
    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:507)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:230)

我可以从命令行克隆存储库,也可以git clone在Jenkins项目的预构建步骤中通过执行Shell命令来克隆存储库,因此我对插件配置为何不起作用感到困惑。我以为这可能是身份验证问题,我尝试在.netrc文件中指定凭据并将其包括在URL中(即https://
username:password@git.mycompany.com/git/MyProject.git
),但是在在所有情况下,我仍然遇到相同的错误。有任何想法吗?


问题答案:

这是Jenkins Git插件中的错误。

您可以通过使用凭据插件创建凭据来解决凭据问题,然后在Job的SCM /
Git部分中使用这些凭据。但是,如果签出失败,这将在构建日志中以纯文本形式公开您的用户/密码。

另外,如果您将HTTP代理与git一起使用,则此操作将无效。最好的方法(目前)是使用JGit(在Jenkins配置中配置)。但是,JGit是实验性的,在代理方面也非常有限。

(由于受欢迎的要求而发布的答案;))



 类似资料:
  • 问题内容: 我有一个客户端服务器应用程序。我设法使他们使用SSl加密通过https连接 现在,我想同时使用http和https运行服务器。有什么可行的方法吗? 问题答案: 第一件事:不要使用flask中内置的Web服务器进行繁重的工作。您应该使用真实的Web服务器,例如apache(mod_wsgi)nginex + gunicore等。这些服务器包含有关如何同时运行http和https的文档

  • 我正在使用Spring Boot为一个简单的REST控制器提供一个有角度的应用程序。我配置了全局CORS策略: 现在,在使用普通HTTP时,这工作很好,但是,如果我在中配置TLS,如下所示: 下面是控制台记录的错误消息:

  • 我正在尝试使用undertow组件为一些驼峰路线设置https。当前的camel版本是2.19.4。代码来自一个简单的示例: 非https设置如下所示: 到目前为止,这一切正常,我可以访问和很好。 现在,我配置了自己的密钥库,创建了一个SSLContextParameters对象,并将设置部分更改为: 路由保持与以前相同。现在,camel无法启动服务器并出现以下错误: 然而,如果我删除一个endp

  • 我正在构建一个uber jarfile,但用

  • 我正在使用Jenkins Git插件(v2.0)的分支说明符选项在特定的分支上运行构建,例如,<代码>1.4 。 在这种情况下包含值。 如何接收用于克隆的本地Git分支的名称(即只有没有前缀? 我尝试了使用分支名称查看特定本地分支的其他行为,但没有任何改变。 我在GitHub上看到过相关的PR,但被拒绝了(因为它只修复了一个只有远程的情况)。

  • 我目前正在我的<code>Jenkinsfile 由于我使用的云托管的kubernetes是从dockerd到containerd作为容器运行时,我想问一下是否有人使用带有jenkins kubernetes插件(特别是podtemplates)的containerd。