Skip to content

Support downloading a single artifact file #432

Closed
@JonathonReinhart

Description

@JonathonReinhart

GitLab 10.0 added an API route to download a single artifact file:

GET /projects/:id/jobs/:job_id/artifacts/*artifact_path

Example request:

curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" \
    "https://gitlab.example.com/api/v4/projects/1/jobs/5/artifacts/some/release/file.pdf"

python-gitlab does not appear to support this.

I imagine something like this:

job.get_artifact('some/release/file.pdf', streamed=True, action=whatever)

Activity

JonathonReinhart

JonathonReinhart commented on Feb 9, 2018

@JonathonReinhart
ContributorAuthor
added this to the v1.4 milestone on Feb 14, 2018
gpocentek

gpocentek commented on Mar 2, 2018

@gpocentek
Contributor

Hi @JonathonReinhart

I've had a look at your patch. It looks OK but I'd prefer to have a new actifact method instead of modifying the existing artifacts. Let me know if you want to keep working on this, I'll be happy to review and merge!

Thanks!

JonathonReinhart

JonathonReinhart commented on Mar 17, 2018

@JonathonReinhart
ContributorAuthor

@gpocentek Sorry, I got busy and didn't get a chance to come back to this. I agree with your new, separate method. Thanks for the addition!

Vickey-Wu

Vickey-Wu commented on Apr 12, 2019

@Vickey-Wu

i find we can use python-gitlab's build_or_job.trace() to get artifacts content we need, if you had printed them in your .gitlab-ci.yml

sudo pip install --upgrade python-gitlab
import gitlab

gl = gitlab.Gitlab('https://gitlab.com', private_token='xxxxxxxxxxxxxxx')
project = gl.projects.get(project_id)
job = project.jobs.get(job_id)
info = job.trace()
# find the content printed in trace output and process it to get content you need
...
locked as resolved and limited conversation to collaborators on Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Support downloading a single artifact file · Issue #432 · python-gitlab/python-gitlab