【问题标题】:Cannot download file from gitlab using command line无法使用命令行从 gitlab 下载文件
【发布时间】:2021-02-20 06:48:02
【问题描述】:

我有一个gitlab的内部部署:https://gitlab.corp.mycompany.com/project/account/config-file/repo/blob/long_alphanumeric_numer/my_wanted_file

我想通过命令行下载“my_wanted_file”。它包含配置内容。

我试过了:

curl -o https://gitlab.corp.mycompany.com/project/account/configfile/repo/blob/master/my_wanted_file

wget https://gitlab.corp.mycompany.com/project/account/configfile/repo/blob/master/my_wanted_file

然后我点击“永久链接”并再次尝试:

curl -OL https://gitlab.corp.mycompany.com/project/account/configfile/repo/blob/long_alphanumeric_numer/my_wanted_file

wget https://gitlab.corp.mycompany.com/project/account/configfile/repo/blob/long_alphanumeric_numer/my_wanted_file```

curl 'Private-Token: my_private_token' https://gitlab.corp.mycompany.com/project/account/configfile/repo/blob/long_alphanumeric_numer/my_wanted_file

使用 curl --header 'Private-Token: my_private_token' 加上 url,返回这个消息:

<html><body>You are being 
<a href="https://gitlab.corp.my_company.com/users/sign_in">redirected</a>.</body></html>

在所有情况下,我确实得到了一个带有 java 脚本内容的奇怪文件,但从来没有 my_wanted_file 当前在 gitlab 中显示的配置文件内容。

我认为让大家知道我正在通过 okta 连接到这个私有 gitlab 部署是很重要的。不确定这是否会在中间引入一些噪音,因此需要提供不同的命令。

你能指点一下吗?

【问题讨论】:

标签: curl command-line gitlab wget okta


【解决方案1】:

对于这种情况,最好使用 Gitlab API,特别是 Repository File API 从存储库获取文件:

curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.corp.mycompany.com/api/v4/projects/<project_id>/repository/files/my_wanted_file?ref=master"

按照这些instructions创建您的个人令牌。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-09
    • 1970-01-01
    • 2022-10-15
    • 2018-12-16
    • 1970-01-01
    • 2012-05-03
    • 1970-01-01
    相关资源
    最近更新 更多