Documentation
¶
Overview ¶
Package ci reports the continuous-integration job a scan is running in.
The facts here exist once, in the process doing the work, and are gone when it exits. Nothing downstream can recover them: a report names a repository and cannot say which workflow produced the scan, so "which pipeline published this, and can I go and look at it" is unanswerable from the artifact alone.
Every value is read from a named variable on a named platform. Nothing scans the environment, which is what keeps a token that happens to be exported out of a document that gets published.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
// System names the platform: "github-actions", "gitlab-ci", "azure-pipelines", "circleci",
// "buildkite".
System string `json:"system" yaml:"system"`
// Repository is the repository the pipeline is for, in the platform's own spelling.
Repository string `json:"repository,omitempty" yaml:"repository,omitempty"`
// Ref is the branch or tag being built.
Ref string `json:"ref,omitempty" yaml:"ref,omitempty"`
// Workflow and Job locate the scan within the pipeline. A repository usually has several
// pipelines and a pipeline several jobs, so neither identifies it alone.
Workflow string `json:"workflow,omitempty" yaml:"workflow,omitempty"`
Job string `json:"job,omitempty" yaml:"job,omitempty"`
// RunID is the platform's identifier for this run, and Attempt distinguishes a retry of a
// failed run from a fresh one. Together they are what a run key is derived from.
//
// Attempt is set only where the platform reuses the run id across attempts, which today is
// GitHub Actions. Elsewhere a retry already has an id of its own and qualifying it further
// would make every first attempt look like a retry.
RunID string `json:"runId,omitempty" yaml:"runId,omitempty"`
Attempt string `json:"attempt,omitempty" yaml:"attempt,omitempty"`
// URL is where a person can go and read the job's own logs. Absent where the platform does not
// publish enough to build one. A guessed URL is worse than none.
URL string `json:"url,omitempty" yaml:"url,omitempty"`
}
Context is the job a scan ran in, or the zero value when it did not run in one.
func (Context) JobID ¶
JobID identifies this job to a platform, or "" outside CI.
Attempt-qualified where the platform distinguishes attempts, because a re-run of a failed job is a different event from the attempt that failed, and a key that could not tell them apart would have the retry refused as a duplicate.