简体   繁体   English

无法使用命令行从 gitlab 下载文件

[英]Cannot download file from gitlab using command line

I have an internal deployment of gitlab: https://gitlab.corp.mycompany.com/project/account/config-file/repo/blob/long_alphanumeric_numer/my_wanted_file我有 gitlab 的内部部署: https ://gitlab.corp.mycompany.com/project/account/config-file/repo/blob/long_alphanumeric_numer/my_wanted_file

I want to download "my_wanted_file" via command line.我想通过命令行下载“my_wanted_file”。 It contains configuration stuff.它包含配置的东西。

I tried so far:我到目前为止尝试过:

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

Then I clicked "permalink" and tried again with:然后我点击“永久链接”并再次尝试:

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

Using curl --header 'Private-Token: my_private_token' plus url, returns this msg:使用 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>

In all cases I do get a weird file with java script stuff but never the config file content that my_wanted_file currently shows in gitlab.在所有情况下,我确实得到了一个带有 java 脚本内容的奇怪文件,但从未得到my_wanted_file当前在 gitlab 中显示的配置文件内容。

I think it's important to let you know guys that I'm connecting to this private gitlab deployment via okta.我认为让你们知道我正在通过 okta 连接到这个私有 gitlab 部署是很重要的。 Not sure if that is introducing some noise in the middle and, therefore a different command needs to be supplied.不确定这是否会在中间引入一些噪音,因此需要提供不同的命令。

Could you please advice?你能指点一下吗?

For such case, it's better to use Gitlab API and specially Repository File API to get file from repository :对于这种情况,最好使用 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"

Create your personal token following these instructions .按照这些说明创建您的个人令牌。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM