step

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Overview

Package step consists of the buildkite DSL for defining various types of steps.

For more details, refer this docs page.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutomaticRetry

type AutomaticRetry struct {
	ExitStatus *string `json:"exit_status,omitempty"`
	Limit      *int    `json:"limit,omitempty"`
}

type Block added in v0.5.0

type Block struct {
	// Block step name.
	//
	// Example: "Release"
	Block string `json:"block"`

	// The state that the build is set to when the build is blocked by this block step.
	// The default is passed. When the blocked_state of a block step is set to failed,
	// the step that triggered it will be stuck in the running state until it is manually unblocked.
	//
	// Values: passed, failed, running
	BlockedState *BlockedState `json:"blocked_state,omitempty"`

	// A unique string to identify the block step.
	Key *string `json:"key,omitempty"`

	BlockAttributes
}

Block is used to created a Block step in buildkite.

For more details, refer: https://buildkite.com/docs/pipelines/block-step

func (Block) Step added in v0.5.0

func (Block) Step()

Step is defined on Block step to allow it to be used as pipeline.Step

type BlockAttributes added in v0.5.0

type BlockAttributes struct {
	// The instructional message displayed in the dialog box when the unblock step is activated.
	//
	// Example: "Release to production?"
	// Example: "Fill out the details for this release"
	Prompt *string `json:"prompt,omitempty"`

	// A list of input fields required to be filled out before unblocking the step.
	//
	// Available input field types: text, select
	Fields []Field `json:"fields,omitempty"`

	// The [branch pattern] defining which branches will include this step in their builds.
	//
	// Example: "main stable/*"
	//
	// [branch pattern]: https://buildkite.com/docs/pipelines/branch-configuration#branch-pattern-examples
	Branches *string `json:"branches,omitempty"`

	// A boolean expression that omits the step when false. See [Using conditionals] for supported expressions.
	//
	// Example: build.message != "skip me"
	//
	// [Using conditionals]: https://buildkite.com/docs/pipelines/conditionals
	If *string `json:"if,omitempty"`

	// A list of step keys that this step depends on. This step will only
	// run after the named steps have completed.
	DependsOn []Dependency `json:"depends_on,omitempty"`

	// Whether to continue to run this step if any of the steps named in the depends_on attribute fail.
	AllowDependencyFailure *bool `json:"allow_dependency_failure,omitempty"`
}

type BlockedState added in v0.5.0

type BlockedState string
const (
	Passed  BlockedState = "passed"
	Failed  BlockedState = "failed"
	Running BlockedState = "running"
)

type Build added in v0.5.0

type Build struct {
	// The message for the build. Supports emoji. Default: the label of the trigger step.
	//
	// Example: "Triggered build"
	Message *string `json:"message,omitempty"`

	// The commit hash for the build. Default: "HEAD"
	//
	// Example: "ca82a6d"
	Commit *string `json:"commit,omitempty"`

	// The branch for the build.
	//
	// Default: The triggered pipeline's default branch.
	// Example: "production"
	Branch *string `json:"branch,omitempty"`

	// A map of meta-data for the build.
	//
	// Example: release-version: "1.1"
	Metadata map[string]string `json:"meta_data,omitempty"`

	// A map of environment variables for the build.
	//
	// Example: RAILS_ENV: "test"
	Env map[string]string `json:"env,omitempty"`
}

type Command

type Command struct {
	// The shell command to run during this step. This can be a single line of commands.
	//
	// Example: "build.sh"
	Command *string `json:"command,omitempty"`

	// Alias for Command. This is a list of commands that must all pass.
	//
	// Example:
	// - "npm install"
	// - "tests.sh"
	Commands []string `json:"commands,omitempty"`

	// A map of [agent tag] keys to values to [target specific agents] for this step.
	//
	// Example: npm: "true"
	//
	// [agent tag]: https://buildkite.com/docs/agent/v3/cli-start#setting-tags
	// [target specific agents]: https://buildkite.com/docs/agent/v3/cli-start#agent-targeting
	Agents agent.Agent `json:"agents,omitempty"`

	// Whether to continue to run this step if any of the steps named in the depends_on attribute fail.
	AllowDependencyFailure *bool `json:"allow_dependency_failure,omitempty"`

	// The [glob path] or paths of [artifacts] to upload from this step.
	//
	// [glob path]: https://buildkite.com/docs/agent/v3/cli-artifact#uploading-artifacts
	// [artifacts]: https://buildkite.com/docs/agent/v3/cli-artifact
	ArtifactPaths []string `json:"artifact_paths,omitempty"`

	// The [branch pattern] defining which branches will include this step in their builds.
	//
	// Example: "main stable/*"
	//
	// [branch pattern]: https://buildkite.com/docs/pipelines/branch-configuration#branch-pattern-examples
	Branches *string `json:"branches,omitempty"`

	// Setting this attribute to true cancels the job as soon as the build is marked as failing.
	CancelOnBuildFailing *bool `json:"cancel_on_build_failing,omitempty"`

	// The maximum number of jobs created from this step that are allowed to run at the same time.
	// If you use this attribute, you must also define a label for it with the concurrency_group attribute.
	//
	// Example: 3
	Concurrency *uint `json:"concurrency,omitempty"`

	// A unique name for the concurrency group that you are creating.
	// If you use this attribute, you must also define the concurrency attribute.
	//
	// Example: "my-app/deploy"
	ConcurrencyGroup *string `json:"concurrency_group,omitempty"`

	// A list of step keys that this step depends on. This step will only
	// run after the named steps have completed.
	DependsOn []Dependency `json:"depends_on,omitempty"`

	// A map of environment variables for this step.
	Env map[string]string `json:"env,omitempty"`

	// A boolean expression that omits the step when false. See [Using conditionals] for supported expressions.
	//
	// Example: build.message != "skip me"
	//
	// [Using conditionals]: https://buildkite.com/docs/pipelines/conditionals
	If *string `json:"if,omitempty"`

	// A unique string to identify the step. The value is available in the BUILDKITE_STEP_KEY environment variable.
	// Keys can not have the same pattern as a UUID (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
	//
	// Example: "linter"
	Key *string `json:"key,omitempty"`

	// Alias for Key
	Identifier *string `json:"identifier,omitempty"`

	// The label that will be displayed in the pipeline visualisation in Buildkite. Supports [emoji].
	//
	// Example: ":hammer: Tests" will be rendered as "🔨 Tests"
	//
	// [emoji]: https://github.com/buildkite/emojis#emoji-reference
	Label *string `json:"label,omitempty"`

	// Array of values to be used in matrix expansion.
	//
	// This library intentionally does not support advanced matrix configurations like `setup` and `adjustments`.
	// Preference would be to instead use for loops in Go to construct a set of jobs that we aim for the matrix to contain.
	// Another reason is the limitation of such configurations: https://buildkite.com/docs/pipelines/build-matrix#matrix-limits
	Matrix []string `json:"matrix,omitempty"`

	// The number of parallel jobs that will be created based on this step.
	//
	// Example: 3
	Parallelism *uint `json:"parallelism,omitempty"`

	// An array of [plugins] for this step.
	//
	// [plugins]: https://buildkite.com/docs/plugins
	Plugins []Plugin `json:"plugins,omitempty"`

	// Adjust the priority for a specific job, as a positive or negative integer.
	Priority *int `json:"priority,omitempty"`

	// Whether to skip this step or not.
	//
	// Use `WithReason(string)` or `WithoutReason()` to populate this.
	Skip *Skip `json:"skip,omitempty"`

	// Allow specified non-zero exit statuses not to fail the build.
	//
	// Use `ForAllNonZeroExitCodes()` to soft fail for any non-zero exit code.
	// Use `ForExitCodes([]uint8)` to soft fail for specific exit codes.
	SoftFail *SoftFail `json:"soft_fail,omitempty"`

	// The maximum number of minutes a job created from this step is allowed to run.
	// If the job exceeds this time limit, or if it finishes with a non-zero exit status,
	// the job is automatically canceled and the build fails.
	// Jobs that time out with an exit status of 0 are marked as "passed".
	//
	// Note that command steps on the Buildkite Free plan have a maximum job timeout of 240 minutes.
	// You can also set default and maximum timeouts in the Buildkite UI.
	//
	// Example: 60
	TimeoutInMinutes uint `json:"timeout_in_minutes,omitempty"`
}

Command is used to created a Command step in buildkite.

For more details, refer: https://buildkite.com/docs/pipelines/command-step

func (Command) Groupable added in v0.5.0

func (Command) Groupable()

Groupable is defined to allow Command step to be used as a step.GroupStep

func (Command) MarshalJSON

func (c Command) MarshalJSON() ([]byte, error)

func (Command) Step added in v0.5.0

func (Command) Step()

Step is defined on Command step to allow it to be used as pipeline.Step

type CommandRetry

type CommandRetry struct {
	Automatic *AutomaticRetry `json:"automatic,omitempty"`
	Manual    *ManualRetry    `json:"manual,omitempty"`
}

type Dependency

type Dependency struct {
	Step         string `json:"step"`
	AllowFailure *bool  `json:"allow_failure,omitempty"`
}

type Field added in v0.5.0

type Field interface {
	MarshalJSON() ([]byte, error)
}

type Group added in v0.5.0

type Group struct {
	// Name of the group in the UI.
	Group string `json:"group"`

	// A list of steps in the group; at least 1 step is required.
	Steps []GroupStep `json:"steps"`

	// Whether to continue to run this step if any of the steps named in the depends_on attribute fail.
	AllowDependencyFailure *bool `json:"allow_dependency_failure,omitempty"`

	// A list of step or group keys that this step depends on.
	// This step or group will only run after the named steps have completed.
	// See [managing step dependencies] for more information.
	//
	// [managing step dependencies]: https://buildkite.com/docs/pipelines/dependencies
	// Example: "test-suite"
	DependsOn []Dependency `json:"depends_on,omitempty"`

	// A unique string to identify the step, block, or group.
	//
	// Example: "test-suite"
	Key *string `json:"key,omitempty"`

	// The label that will be displayed in the pipeline visualisation in Buildkite
	// (name of the group in the UI). Supports emoji.
	//
	// Example: ":hammer: Tests" will be rendered as "🔨 Tests"
	Label *string `json:"label,omitempty"`
}

Group is used to created a Group step in buildkite.

For more details, refer: https://buildkite.com/docs/pipelines/group-step

func (Group) MarshalJSON added in v0.5.0

func (g Group) MarshalJSON() ([]byte, error)

func (Group) Step added in v0.5.0

func (Group) Step()

Step is defined on Group step to allow it to be used as pipeline.Step

type GroupStep added in v0.5.0

type GroupStep interface {
	Groupable()
}

type Input added in v0.5.0

type Input struct {
	// Input step name.
	//
	// Example: "Release"
	Input string `json:"input"`

	BlockAttributes
}

Input is used to created a Block step in buildkite.

For more details, refer: https://buildkite.com/docs/pipelines/input-step

type ManualRetry

type ManualRetry struct {
	Allowed        *bool   `json:"allowed,omitempty"`
	PermitOnPassed *bool   `json:"permit_on_passed,omitempty"`
	Reason         *string `json:"reason,omitempty"`
}

type Plugin added in v0.4.0

type Plugin interface {
	Name() string
	Version() string

	json.Marshaler
}

type SelectField added in v0.5.0

type SelectField struct {
	// The meta-data key that stores the field's input (using the buildkite-agent meta-data command)
	// The key may only contain alphanumeric characters, slashes or dashes.
	//
	// Example: "release-stream"
	Key string `json:"key"`

	// The list of select field options.
	// For 6 or less options they'll be displayed as radio buttons, otherwise they'll be displayed in a dropdown box.
	// If selecting multiple options is permitted the options will be displayed as checkboxes.
	Options []SelectFieldOption `json:"options"`

	// A boolean value that defines whether multiple options may be selected.
	// When multiple options are selected, they are delimited in the meta-data field by a line break (\n)
	//
	// Default: false
	Multiple *bool `json:"bool,omitempty"`

	// The text displayed directly under the select field's label.
	//
	// Example: "Which release stream does this belong in? :fork:"
	Hint *string `json:"hint,omitempty"`

	// A boolean value that defines whether the field is required for form submission.
	//
	// Default: true
	Required *bool `json:"required,omitempty"`

	// The value of the option or options that will be pre-selected.
	// When multiple is enabled, this can be an array of values to select by default.
	//
	// Example: "beta"
	Default *string `json:"default,omitempty"`
}

func (SelectField) MarshalJSON added in v0.5.0

func (s SelectField) MarshalJSON() ([]byte, error)

type SelectFieldOption added in v0.5.0

type SelectFieldOption struct {
	// The text displayed for the option.
	//
	// Example: "Stable"
	Label string `json:"label"`

	// The value to be stored as meta-data (to be later retrieved using the buildkite-agent meta-data command)
	//
	// Example: "stable"
	Value string `json:"value"`
}

type Skip

type Skip struct {
	Reason *string
}

func WithReason

func WithReason(reason string) *Skip

func WithoutReason

func WithoutReason() *Skip

func (Skip) MarshalJSON

func (s Skip) MarshalJSON() ([]byte, error)

type SoftFail

type SoftFail struct {
	ExitCodes []uint8
}

func ForAllNonZeroExitCodes

func ForAllNonZeroExitCodes() *SoftFail

func ForExitCodes

func ForExitCodes(exitCodes []uint8) *SoftFail

func (SoftFail) MarshalJSON

func (s SoftFail) MarshalJSON() ([]byte, error)

type TextField added in v0.5.0

type TextField struct {
	// The meta-data key that stores the field's input (using the buildkite-agent meta-data command)
	// The key may only contain alphanumeric characters, slashes or dashes.
	//
	// Example: "release-name"
	Key string `json:"key"`

	// Text field name
	//
	// Example: "Release Name"
	Text *string `json:"text,omitempty"`

	// The explanatory text that is shown after the label.
	//
	// Example: "What's the code name for this release? :name_badge:"
	Hint *string `json:"hint,omitempty"`

	// A boolean value that defines whether the field is required for form submission.
	Required *bool `json:"required,omitempty"`

	// The value that is pre-filled in the text field.
	//
	// Example: "Flying Dolphin"
	Default *string `json:"default,omitempty"`
}

func (TextField) MarshalJSON added in v0.5.0

func (t TextField) MarshalJSON() ([]byte, error)

type Trigger added in v0.5.0

type Trigger struct {
	// The slug of the pipeline to create a build. You can find it in the URL of your pipeline,
	// and it corresponds to the name of the pipeline, converted to kebab-case.
	//
	// Example: "another-pipeline"
	PipelineSlug pipeline.Slug `json:"trigger"`

	// An optional map of attributes for the triggered build.
	Build *Build `json:"build,omitempty"`

	// The label that will be displayed in the pipeline visualisation in Buildkite. Supports emoji.
	//
	// Example: ":rocket: Deploy"
	Label *string `json:"label,omitempty"`

	// If set to true the step will immediately continue, regardless of the success
	// of the triggered build. If set to false the step will wait for the triggered build to complete
	// and continue only if the triggered build passed. Note that when async is set to true, as long
	// as the triggered build starts, the original pipeline will show that as successful.
	// The original pipeline does not get updated after subsequent steps or after the triggered build completes.
	//
	// Default value: false
	Async *bool `json:"async,omitempty"`

	// The [branch pattern] defining which branches will include this step in their builds.
	//
	// Example: "main stable/*"
	//
	// [branch pattern]: https://buildkite.com/docs/pipelines/branch-configuration#branch-pattern-examples
	Branches *string `json:"branches,omitempty"`

	// A boolean expression that omits the step when false. See [Using conditionals] for supported expressions.
	//
	// Example: build.message != "skip me"
	//
	// [Using conditionals]: https://buildkite.com/docs/pipelines/conditionals
	If *string `json:"if,omitempty"`

	// A list of step keys that this step depends on. This step will only
	// run after the named steps have completed.
	DependsOn []Dependency `json:"depends_on,omitempty"`

	// Whether to continue to run this step if any of the steps named in the depends_on attribute fail.
	AllowDependencyFailure *bool `json:"allow_dependency_failure,omitempty"`

	// Whether to skip this step or not.
	//
	// Use `WithReason(string)` or `WithoutReason()` to populate this.
	Skip *Skip `json:"skip,omitempty"`
}

Trigger is used to created a Trigger step in buildkite.

For more details, refer: https://buildkite.com/docs/pipelines/trigger-step

func (Trigger) Groupable added in v0.5.0

func (Trigger) Groupable()

Groupable is defined to allow Trigger step to be used as a step.GroupStep

func (Trigger) MarshalJSON added in v0.5.0

func (t Trigger) MarshalJSON() ([]byte, error)

func (Trigger) Step added in v0.5.0

func (Trigger) Step()

Step is defined on Trigger step to allow it to be used as pipeline.Step

type Wait added in v0.4.0

type Wait struct {
	// Run the next step, even if the previous step has failed.
	ContinueOnFailure *bool `json:"continue_on_failure,omitempty"`

	// A boolean expression that omits the step when false. See [Using conditionals] for supported expressions.
	//
	// Example: build.message != "skip me"
	//
	// [Using conditionals]: https://buildkite.com/docs/pipelines/conditionals
	If *string `json:"if,omitempty"`

	// A list of step keys that this step depends on. This step will only
	// run after the named steps have completed.
	DependsOn []Dependency `json:"depends_on,omitempty"`

	// Whether to continue to run this step if any of the steps named in the depends_on attribute fail.
	AllowDependencyFailure *bool `json:"allow_dependency_failure,omitempty"`
}

Wait is used to created a Wait step in buildkite.

For more details, refer: https://buildkite.com/docs/pipelines/wait-step

func (Wait) Groupable added in v0.5.0

func (Wait) Groupable()

Groupable is defined to allow Wait step to be used as a step.GroupStep

func (Wait) MarshalJSON added in v0.4.0

func (w Wait) MarshalJSON() ([]byte, error)

func (Wait) Step added in v0.5.0

func (Wait) Step()

Step is defined on Wait step to allow it to be used as pipeline.Step

Jump to

Keyboard shortcuts

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