Skip to content

Instantly share code, notes, and snippets.

@ingvaldlorentzen
Created January 3, 2022 15:10
Show Gist options
  • Save ingvaldlorentzen/2adf50aa06dcd173eca8f3de73e09f59 to your computer and use it in GitHub Desktop.
Save ingvaldlorentzen/2adf50aa06dcd173eca8f3de73e09f59 to your computer and use it in GitHub Desktop.
GitLab Delete Pipeline Artifacts
import os
from gitlab import Gitlab
gitlab = Gitlab(os.environ['CI_SERVER_URL'], private_token=os.environ['GITLAB_API_TOKEN'])
project = gitlab.projects.get(os.environ['CI_PROJECT_PATH'])
pipeline = project.pipelines.get(os.environ['CI_PIPELINE_ID'])
for pipeline_job in pipeline.jobs.list():
job = project.jobs.get(pipeline_job.id)
job.delete_artifacts()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment