gpt4 book ai didi

linux - 直接从 GitLab 私有(private)仓库打开文件

转载 作者:IT王子 更新时间:2023-10-29 00:23:26 25 4
gpt4 key购买 nike

我在 GitLab 服务器上有一个私有(private)存储库,使用 SSH 我可以使用 git clone pull 一个项目。

但我想直接从服务器在 linux 命令行上运行脚本(更具体地说,一个 Drupal/Drush .make 文件)

我尝试使用原始文件运行它:

drush make http://server.com/user/project/raw/master/file.make

(为了方便非 Drupal 用户假设)

curl http://server.com/user/project/raw/master/file.make

没有成功。当然,它会返回登录页面。

这可能吗?

最佳答案

Chris的宝贵帮助,这里是如何从 GitLab 服务器运行脚本(在我的例子中是 drupal .make 文件)。 (可能它适用于 GitHub,但我没有测试它。也许语法会有点不同)。 (当然这适用于任何类型的脚本)

可以使用身份验证 token 来完成。 Here is the documentation of the GitLab's APIhere is the GitHub's API

为方便起见,我将使用 https://gitlab.com作为示例服务器。

  • 转到 https://gitlab.com/profile/account并找到你的“私有(private) token ”

  • 然后打印项目列表并找到您要查找的项目的id

    curl https://gitlab.com/api/v3/projects?private_token=<your_private_token>

    或者使用您的浏览器访问那里(json viewer 会有很大帮助)

  • 然后打印该项目中的文件列表并找到您要查找的文件的 ID

    curl https://gitlab.com/api/v3/projects/<project_id>/repository/tree?private_token=<your_private_token>

  • 终于获取/运行文件了!

    curl https://gitlab.com/api/v3/projects/<project_id>/repository/raw_blobs/<file_id>?private_token=<your_private_token>

如果您想运行脚本 (drupal .make)

drush make https://gitlab.com/api/v3/projects/<project_id>/repository/raw_blobs/<file_id>?private_token=<your_private_token> <drupal_folder>

(如果你在这里寻找一个工作流程来集成 GitLab 和 Aegir .make 平台而不使用 token (也许是 SSH?)请创建一个线程并将链接粘贴到这里。)

编辑

您可以在没有 project_id 的情况下获取文件通过使用编码 项目名称。例如 my-user-name/my-project将变为:my-user-name%2Fmy-project

关于linux - 直接从 GitLab 私有(private)仓库打开文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24207644/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com