簡體   English   中英

jenkins如何構建/克隆安裝在其docker容器中的遠程git repo?

[英]how can a jenkins build/clone a remote git repo which is mounted into it's docker container?

我有一個支持Docker容器的私有Synology NAS Cloud。 現在,我計划一個私有構建並部署管道或類似的東西。

我完成的第一步:

  1. 在Synology上安裝Git Server
  2. 初始化一些倉庫
  3. 將它們克隆到我的MacBook上
  4. 通過ssh進行通信(提交,推送,拉出)

->一切正常。

現在,我已經使用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.

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