微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决无法使用命令行从gitlab下载文件

我有一个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部署很重要。不知道这是否在中间引入了一些噪音,因此需要提供不同的命令。

可以请教吗?

解决方法

在这种情况下,最好使用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之后创建您的个人令牌。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。