import gitlab
URL = 'https://gitlab.example.com'
ACCESS_TOKEN = '555555555555'
# May not be needed depending on the infrastructure for your Gitlab.
# For mine Gitlab is self hosted so adding in my root CA is necessary.
CA_CERT = '/path/to/ca'
FILENAME = 'test.tar.gz'
PROJECT_ID = 1
gl = gitlab.Gitlab(URL, ACCESS_TOKEN, ssl_verify=CA_CERT)
gl.auth()
project = gl.projects.get(PROJECT_ID)
tgz = project.repository_archive()
with open(FILENAME, 'wb') as f:
f.write(tgz)