syntax

package
v1.3.853 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PipelineAPIVersion the APIVersion for using Build Pipeline
	PipelineAPIVersion = "pipeline.knative.dev/v1alpha1"
)

Variables

This section is empty.

Functions

func MangleToRfc1035Label

func MangleToRfc1035Label(body string, suffix string) string

MangleToRfc1035Label - Task/Step names need to be RFC 1035/1123 compliant DNS labels, so we mangle them to make them compliant. Results should match the following regex and be no more than 63 characters long:

[a-z]([-a-z0-9]*[a-z0-9])?

cf. https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names body is assumed to have at least one ASCII letter. suffix is assumed to be alphanumeric and non-empty. TODO: Combine with kube.ToValidName (that function needs to handle lengths)

Types

type Agent

type Agent struct {
	// One of label or image is required.
	Label string `yaml:"label,omitempty"`
	Image string `yaml:"image,omitempty"`
}

Agent defines where the pipeline, stage, or step should run.

type EnvVar

type EnvVar struct {
	Name  string `yaml:"name"`
	Value string `yaml:"value"`
}

EnvVar is a key/value pair defining an environment variable

type PipelineStructure

type PipelineStructure struct {
	Agent       Agent       `yaml:"agent,omitempty"`
	Environment []EnvVar    `yaml:"environment,omitempty"`
	Options     RootOptions `yaml:"options,omitempty"`
	Stages      []Stage     `yaml:"stages"`
	Post        []Post      `yaml:"post,omitempty"`
}

PipelineStructure is the internal representation of the Pipeline, used to validate and create CRDs

func ParseJenkinsfileYaml

func ParseJenkinsfileYaml(jenkinsfileYaml string) (*PipelineStructure, error)

ParseJenkinsfileYaml takes a YAML string and parses it.

func (*PipelineStructure) GenerateCRDs

func (j *PipelineStructure) GenerateCRDs(pipelineIdentifier string, buildIdentifier string, namespace string, suffix string, podTemplates map[string]*corev1.Pod) (*pipelinev1alpha1.Pipeline, []*pipelinev1alpha1.Task, error)

GenerateCRDs translates the Pipeline structure into the corresponding Pipeline and Task CRDs

func (*PipelineStructure) Validate

func (j *PipelineStructure) Validate() *apis.FieldError

Validate checks the parsed PipelineStructure to find any errors in it. TODO: Improve validation to actually return all the errors via the nested errors? TODO: Add validation for the not-yet-supported-for-CRD-generation sections

type Post

type Post struct {
	// TODO: Conditional execution of something after a Task or Pipeline completes is not yet implemented
	Condition PostCondition `yaml:"condition"`
	Actions   []PostAction  `yaml:"actions"`
}

Post contains a PostCondition and one more actions to be executed after a pipeline or stage if the condition is met.

type PostAction

type PostAction struct {
	// TODO: Notifications are not yet supported in Build Pipeline per se.
	Name string `yaml:"name"`
	// Also, we'll need to do some magic to do type verification during translation - i.e., this action wants a number
	// for this option, so translate the string value for that option to a number.
	Options map[string]string `yaml:"options,omitempty"`
}

PostAction contains the name of a built-in post action and options to pass to that action.

type PostCondition

type PostCondition string

PostCondition is used to specify under what condition a post action should be executed.

const (
	PostConditionSuccess PostCondition = "success"
	PostConditionFailure PostCondition = "failure"
	PostConditionAlways  PostCondition = "always"
)

Probably extensible down the road

type RootOptions

type RootOptions struct {
	Timeout Timeout `yaml:"timeout,omitempty"`
	// TODO: Not yet implemented in build-pipeline
	Retry int8 `yaml:"retry,omitempty"`
}

RootOptions contains options that can be configured on either a pipeline or a stage

type Stage

type Stage struct {
	Name        string       `yaml:"name"`
	Agent       Agent        `yaml:"agent,omitempty"`
	Options     StageOptions `yaml:"options,omitempty"`
	Environment []EnvVar     `yaml:"environment,omitempty"`
	Steps       []Step       `yaml:"steps,omitempty"`
	Stages      []Stage      `yaml:"stages,omitempty"`
	Parallel    []Stage      `yaml:"parallel,omitempty"`
	Post        []Post       `yaml:"post,omitempty"`
}

Stage is a unit of work in a pipeline, corresponding either to a Task or a set of Tasks to be run sequentially or in parallel with common configuration.

type StageOptions

type StageOptions struct {
	RootOptions `yaml:",inline"`

	// TODO: Not yet implemented in build-pipeline
	Stash   Stash   `yaml:"stash,omitempty"`
	Unstash Unstash `yaml:"unstash,omitempty"`

	Workspace *string `yaml:"workspace,omitempty"`
}

StageOptions contains both options that can be configured on either a pipeline or a stage, via RootOptions, or stage-specific options.

type Stash

type Stash struct {
	Name string `yaml:"name"`
	// Eventually make this optional so that you can do volumes instead
	Files string `yaml:"files"`
}

Stash defines files to be saved for use in a later stage, marked with a name

type Step

type Step struct {
	// One of command or step is required.
	Command string `yaml:"command,omitempty"`
	// args is optional, but only allowed with command
	Arguments []string `yaml:"args,omitempty"`
	// dir is optional, but only allowed with command. Refers to subdirectory of workspace
	Dir string `yaml:"dir,omitempty"`

	Step string `yaml:"step,omitempty"`
	// options is optional, but only allowed with step
	// Also, we'll need to do some magic to do type verification during translation - i.e., this step wants a number
	// for this option, so translate the string value for that option to a number.
	Options map[string]string `yaml:"options,omitempty"`

	// agent can be overridden on a step
	Agent Agent `yaml:"agent,omitempty"`
}

Step defines a single step, from the author's perspective, to be executed within a stage.

type Timeout

type Timeout struct {
	Time int64 `yaml:"time"`
	// Has some sane default - probably seconds
	Unit TimeoutUnit `yaml:"unit,omitempty"`
}

Timeout defines how long a stage or pipeline can run before timing out.

type TimeoutUnit

type TimeoutUnit string

TimeoutUnit is used for calculating timeout duration

const (
	TimeoutUnitSeconds TimeoutUnit = "seconds"
	TimeoutUnitMinutes TimeoutUnit = "minutes"
	TimeoutUnitHours   TimeoutUnit = "hours"
	TimeoutUnitDays    TimeoutUnit = "days"
)

The available time units.

type Unstash

type Unstash struct {
	Name string `yaml:"name"`
	Dir  string `yaml:"dir,omitempty"`
}

Unstash defines a previously-defined stash to be copied into this stage's workspace

Jump to

Keyboard shortcuts

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