artifacts

package
v1.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package artifacts implements the business logic for fetching and downloading CircleCI job artifacts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Download

func Download(ctx context.Context, client Client, entries []Entry, dir string) error

Download fetches each entry's artifact and writes it under dir, preserving the artifact's Path as the relative file path. When entries span multiple execution indices, each execution's artifacts are placed under a subdirectory named by the index (e.g. dir/exec-0000/path, dir/exec-0003/path).

func DownloadPaths added in v1.0.48340

func DownloadPaths(ctx context.Context, client Client, entries []Entry, dir string) error

DownloadPaths fetches each entry's artifact and writes it at dir/<Path>, applying no layout of its own — the caller has already put whatever structure it wants in each Path. Use it when the destination layout is decided elsewhere (the run-get artifact browser downloads exactly the paths it displayed, for any subset of a job's artifacts); use Download to have the per-execution grouping derived from the entries themselves.

func ExecDir

func ExecDir(idx int) string

ExecDir returns the zero-padded directory name for an execution index.

func FormatMarkdown

func FormatMarkdown(entries []Entry) string

FormatMarkdown returns a markdown string listing the artifacts. When all entries share the same execution index the output is a flat list. When multiple executions are present, entries are grouped under ## Execution N headings.

func FormatRunMarkdown added in v1.16.0

func FormatRunMarkdown(jobs []JobArtifacts) string

FormatRunMarkdown returns one markdown section per job, headed by its workflow and job name, listing paths as FormatMarkdown does. The caller writes any heading for the run itself.

func SafeDirName added in v1.16.0

func SafeDirName(name string) string

SafeDirName turns a workflow or job name into a single path component, for laying out a run's downloads as <dir>/<workflow>/<job>/. Path separators and characters Windows forbids in file names become "_", and a name that would be empty, "." or ".." becomes "_", so the result never leaves its parent.

Types

type Client

type Client interface {
	GetJobArtifactsV3(ctx context.Context, jobID string) ([]apiclient.Artifact, error)
	GetJobV3(ctx context.Context, id uuid.UUID) (*apiclient.JobV3, error)
	DownloadArtifact(ctx context.Context, artifactURL string, dst io.Writer) error
}

Client is the subset of apiclient.Client methods we need.

type Entry

type Entry struct {
	Path      string `json:"path"`
	URL       string `json:"url"`
	Execution int    `json:"execution"`
}

Entry is a single artifact produced by a job.

func ForJob

func ForJob(ctx context.Context, client Client, jobID string) ([]Entry, error)

ForJob fetches artifacts for a job identified by UUID.

The artifacts endpoint answers 404 both for a job that does not exist and for a job that stored no artifacts, so on a 404 ForJob asks the job endpoint which one it is. A job that exists returns an empty list; otherwise ForJob returns the job endpoint's error. An ID that is not a UUID keeps the artifacts 404.

type JobArtifacts added in v1.16.0

type JobArtifacts struct {
	Workflow string
	Job      string
	Entries  []Entry
}

JobArtifacts is one job's artifacts in a run-wide listing, labelled with the workflow and job it came from.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL