[英]how can a jenkins build/clone a remote git repo which is mounted into it's docker container?
我有一个支持Docker容器的私有Synology NAS Cloud。 现在,我计划一个私有构建并部署管道或类似的东西。
我完成的第一步:
->一切正常。
现在,我已经使用Jenkins映像在NAS上启动了一个Docker容器。 我希望Jenkins在NAS上轮询我的远程存储库(我在MacBook上克隆的相同存储库)。 我还将带有所有远程存储库的“ / git”文件夹安装到Jenkins Docker容器中。
因此,我想将存储库URL添加到Jenkins作业中:
file:///git/firstRepo
--->但这不起作用:(
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from file:///git/firstRepo
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:817)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1084)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1115)
at hudson.scm.SCM.checkout(SCM.java:495)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1276)
at
hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild. java:560)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:485)
at hudson.model.Run.execute(Run.java:1735)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:405)
Caused by: hudson.plugins.git.GitException: Command "/usr/bin/git fetch --tags --progress file:///git/firstRepo +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: fatal: '/git/firstRepo' does not appear to be a git repository
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:1924)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1643)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:71)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:352)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:815)
... 11 more
ERROR: Error fetching remote repo 'origin'
Finished: FAILURE
我测试了通过docker shell将仓库复制到Jenkins工作区中
git clone file:///git/firstRepo
->有效。 但是,我以“ root”身份登录。
所以我的问题是:
Jenkins如何访问git文件夹? 访问权限是否有问题? 显然,詹金斯不是“根”。 我是否必须将git文件夹“塞”给我的Jenkins用户(我认为是“ admin”)?
非常感谢!
首先,检查路径:通常,那些存储库(用于推送)是裸存储库,这意味着它们的路径应该是带有.git扩展名的文件夹。
.../git/firstRepo.git
其次,尝试通过简单的构建步骤进行简单的Jenkins Job(无任何SCM设置)
id -a
ls -alrth /git
ls -alrth /git/firstRepo
ls -alrth /git/firstRepo.git
这将向您显示与这些路径关联的权限,并告诉您Jenkins(以id -a
所示的用户身份执行)是否有权访问该路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.