1

I have an internal deployment of 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. 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:

<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.

I think it's important to let you know guys that I'm connecting to this private gitlab deployment via okta. Not sure if that is introducing some noise in the middle and, therefore a different command needs to be supplied.

Could you please advice?

pedro
  • 157
  • 1
  • 12

1 Answers1

0

For such case, it's better to use Gitlab API and specially Repository File API to get file from repository :

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.

Nicolas Pepinster
  • 5,413
  • 2
  • 30
  • 48