系统相关
首页 > 系统相关> > linux – 直接从GitLab私有存储库打开文件

linux – 直接从GitLab私有存储库打开文件

作者:互联网

我在GitLab服务器上有一个私有存储库,使用SSH我可以使用git clone拉一个项目.

但我想直接从服务器上运行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,但我没有测试它.也许语法会有所不同). (当然这适用于任何类型的脚本)

可以使用身份验证令牌来完成. Here is the documentation of the GitLab’s APIhere is the GitHub’s API

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

>转到https://gitlab.com/profile/account并找到您的“私人令牌”
>然后打印项目列表并找到您要查找的项目的ID

curl https://gitlab.com/api/v3/projects?private_token=\u0026lt;your_private_token\u0026gt;

或者去你的浏览器(json viewer会有很多帮助)
>然后打印此项目中的文件列表,并找到您要查找的文件的ID

curl https://gitlab.com/api/v3/projects/\u0026lt;project_id\u0026gt;/repository/tree?private_token=\u0026lt;your_private_token\u0026gt;
>最后获取/运行文件!

curl https://gitlab.com/api/v3/projects/\u0026lt;project_id\u0026gt;/repository/raw_blobs/\u0026lt;file_id\u0026gt;?private_token=\u0026lt;your_private_token\u0026gt;

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

drush make https://gitlab.com/api/v3/projects/\u0026lt;project_id\u0026gt;/repository/raw_blobs/\u0026lt;file_id\u0026gt;?private_token=\u0026lt;your_private_token\u0026gt; &LT drupal_folder&GT

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

编辑

您可以使用编码的项目名称获取没有project_id的文件.例如,my-user-name / my-project将成为:my-user-name / my-project

标签:drush,linux,git,gitlab,drupal
来源: https://codeday.me/bug/20191004/1852007.html