Repository navigation
Closed
Description
Hello, I'm not quite sure why this is failing. My understanding is I should be able to use the path correctly to retrieve the artifact, but it completely fails for me.
This may have something to do with the fact that my artifact has spaces in its path?
Description of the problem, including code/CLI snippet
I'm trying to download a single artifact from a pipeline job.
Expected Behavior
- Get Pipeline
- Get Pipeline Job
- Convert Pipeline Job to a Job
- Get the artifact by path from the job
Actual Behavior
- Get Pipeline
- Get Pipeline Job
- Convert Pipeline Job to a Job
- Get the artifact by path from the job, except it returns an error saying the attribute does not exist
(venv) ╭─user ~/Repositories/ExampleRepo ‹feature/ci-ci-testing*›
╰─$ python gitlab_artifact.py 1 ↵
Traceback (most recent call last):
File "gitlab_artifact.py", line 60, in <module>
main()
File "gitlab_artifact.py", line 52, in main
a = most_recent_job.artifact("ExampleRepo/cached_service_specs.json")
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/cli.py", line 43, in wrapped_f
return f(*args, **kwargs)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/exceptions.py", line 251, in wrapped_f
return f(*args, **kwargs)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/v4/objects.py", line 1397, in artifact
return utils.response_content(result, streamed, action, chunk_size)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/utils.py", line 28, in response_content
return response.content
AttributeError: 'list' object has no attribute 'content'
Specifications
- python-gitlab version: 1.7.0
- API version you are using (v3/v4): Unknown
- Gitlab server version (or gitlab.com): GitLab Enterprise Edition 11.6.3-ee
Here is the script I've written that is failing
# Python Standard Libraries
# N/A
# Third-Party Libraries
import gitlab
# Custom Libraries
# N/A
SERVER_URL = "<REDACTED>"
TOKEN = "<REDACTED>"
PROJECT_ID = <REDACTED>
ARTIFACT_JOB_NAME = "<REDACTED>"
ARTIFACT_NAME = "ExampleRepo/cached_service_specs.json"
def main():
gitlab_client = gitlab.Gitlab(SERVER_URL, private_token=TOKEN)
monitor_project = gitlab_client.projects.get(PROJECT_ID)
pipelines = [pipeline
for pipeline in monitor_project.pipelines.list()
if len(pipeline.jobs.list()) > 0
for job in pipeline.jobs.list()
if job.attributes["name"] == ARTIFACT_JOB_NAME]
if(not (len(pipelines) > 0)):
raise Exception("No pipelines are available to retrieve artifacts from.")
most_recent_pipeline = pipelines[0]
most_recent_pipeline_job = most_recent_pipeline.jobs.list()[0]
most_recent_job = monitor_project.jobs.get(most_recent_pipeline_job.id, lazy=True)
artifact = most_recent_job.artifact(ARTIFACT_NAME)
main()
Activity
[-]Job Artifact Does Not Work[/-][+]Job Artifact Retrieval Does Not Work[/+]gpocentek commentedon Jan 19, 2019
Hi @loganknecht
The artifact you retrieve contains json data so python-gitlab interprets it instead of just returning the content as string. This shouldn't happen obviously.
I'll push a patch ASAP.
fix(api): Don't try to parse raw downloads