如何修复 Docker gradle 中尝试克隆 gitlab 存储库时的“RPC 管道未配置”问题

int*_*ris 9 git gradle rust gitlab docker

我有一个用于 gitlab 存储库的 Docker 容器,需要构建另一个 gitlab 存储库。我们使用 Gradle 脚本来执行 CD/CI。我正在尝试在 Gradle 脚本中编写一个步骤,以将所需的依赖项存储库克隆到我构建和测试依赖项存储库的容器中。我还尝试将依赖项设为 git 子模块,但这也不起作用。

好的,我们有一个用 Rust 编写的应用程序,调用它foo.rs,它依赖于 Apache 许可的开源项目的一个分支bar.rs(我们正在其中添加功能bar,并希望将它们上游回官方 bar 存储库),但我们需要集成功能并确保它们首先与我们的应用程序配合使用。

因此,我们在 gitlab 上有两个存储库://gitlab.com/ourcode/foo.git//gitlab.com/ourcode/bar.git。我有 docker 容器,我在其中构建和测试foo。其中我们有一个.gitlab-ci.yml文件和一个build.gradle用于执行 CD/CI 的文件。最终,我需要让它工作起来,但首先我需要使用 Docker 镜像foo在我的机器上工作。

构建管道中的第一步称为install_deps(安装依赖项)。build.gradle存储库中的代码foo如下所示:

tasks.register(`install_deps`) {
  doLast {
    exec {
      workingDir '.'
      commandLine '/bin/bash' '--login' '-c' 'git clone https:BAR_USER:BAR_PW@gitlab.com/ourcode/bar.git'
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我使用用户 BAR_USER 在 Bar 存储库中的 gitlab 上创建了一个 DEPLOY_TOKEN,而 BAR_PW 是 gitlab 返还给我的神奇字符串。

但是,当我进入foodocker 容器并键入时gradle install_deps,我收到错误:

------ 0% Executing [2s]> :install_deps<-----
Remote-Containers CLI: RPC pipe not configured. Message ("command":"approve",
"stdin":protocol=https:\nhost=gitlab.com=nusername=BAR_USER\nPassword=BAR_PW\n"}
Remote-Containers CLI: RPC pipe not configured. Message ("command":"approve",
"stdin":protocol=https:\nhost=gitlab.com=nusername=BAR_USER\nPassword=BAR_PW\n"}
Run Code Online (Sandbox Code Playgroud)

其中 BAR_PW 当然是魔术字符串。

虽然这比我之前的尝试有所改进。该存储库没有被克隆,如果我尝试这样做,gradle build它将无法工作,因为该存储库无法供 Rust 使用。


我尝试过的其他事情。我尝试制作bar一个子模块foo

在包含存储库的文件系统上foo(由 挂载docker -v /project/foo

tasks.register(`install_deps`) {
  doLast {
    exec {
      workingDir '.'
      commandLine '/bin/bash' '--login' '-c' 'git clone https:BAR_USER:BAR_PW@gitlab.com/ourcode/bar.git'
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

而且,bar回购协议从那里开始,但是gradle build似乎将其删除并失败。

我还尝试使用 Cargo 依赖项来获取它。

[dependencies]
bar = { git = "https://@gitlab.com/ourcode/bar.git", branch="integration" }
Run Code Online (Sandbox Code Playgroud)

并且:

[dependencies]
bar = { git = "https://BAR_USER:BAR_PW@gitlab.com/ourcode/bar.git", branch="integration" }
Run Code Online (Sandbox Code Playgroud)

但这会失败,因为 Docker 不知道如何提供凭据。

Caused by:
  Unable to update https://BAR_USER:BAR_PW@gitlab.com/ourcode/bar.git?branch=integration

Caused by:
  failed to authenticate when downloading repository
Run Code Online (Sandbox Code Playgroud)