Skip to content

Commit

Permalink
Make distinction between no artifacts vs missing file
Browse files Browse the repository at this point in the history
Failed jobs will frequently have *no artifacts*. This change introduces
a new exception type to distinguish between no artifacts and missing
artifacts.
  • Loading branch information
mvandenburgh committed Dec 18, 2024
1 parent 1856ff4 commit 85ae96a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion analytics/analytics/job_processor/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
from gitlab.v4.objects import ProjectJob


class JobHasNoArtifacts(Exception):
def __init__(self, job: ProjectJob) -> None:
message = f"Job {job.id} has no artifacts"
super().__init__(message)


class JobArtifactFileNotFound(Exception):
def __init__(self, job: ProjectJob, filename: str):
message = f"File {filename} not found in job artifacts of job {job.id}"
Expand Down Expand Up @@ -37,7 +43,7 @@ def get_job_artifacts_file(job: ProjectJob, filename: str):
with open(artifacts_file, "wb") as f:
job.artifacts(streamed=True, action=f.write)
except GitlabGetError:
raise JobArtifactFileNotFound(job, filename)
raise JobHasNoArtifacts(job)

# Open specific file within artifacts zip
with zipfile.ZipFile(artifacts_file) as zfile:
Expand Down

0 comments on commit 85ae96a

Please sign in to comment.