I try to download build artifacts from a CI/CD pipeline by using the GitLab API for Python. I took a look at the documentation and wrote the following example:
import os
import time
import gitlab
import subprocess
gl = gitlab.Gitlab("MyRepo.de", private_token = "A Token")
project = gl.projects.get("MyProject")
pipelines = project.pipelines.list()
# Get the latest job from the latest pipeline
CurrentJob = None
for Pipeline in project.pipelines.list():
if(Pipeline.status == "success"):
for Job in Pipeline.jobs.list():
if(Job.status == "success"):
CurrentJob = Job
break
zipfn = "___artifacts.zip"
with open(zipfn, "wb") as f:
CurrentJob.artifacts(streamed=True, action=f.write)
subprocess.run(["unzip", "-bo", zipfn])
os.unlink(zipfn)
But the program exit with the error 'list' object is not callable in the line CurrentJob.artifacts(streamed=True, action=f.write) and the debugger shows three different files:
But the example uses the same lines of code. What is the correct way to access and download the files? I don´t find any solution in the documentation.
