syntax

package
v2.1.108 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2020 License: Apache-2.0 Imports: 26 Imported by: 2

Documentation

Overview

+k8s:deepcopy-gen=package +k8s:openapi-gen=true Package v1 is the v1 version of the API. +groupName=config.jenkins.io +apiVersion=v1

Index

Constants

View Source
const (
	// TektonAPIVersion the APIVersion for using Tekton
	TektonAPIVersion = "tekton.dev/v1alpha1"

	// LabelStageName - the name for the label that will have the stage name on the Task.
	LabelStageName = "jenkins.io/task-stage-name"

	// DefaultStageNameForBuildPack - the name we use for the single stage created from build packs currently.
	DefaultStageNameForBuildPack = "from-build-pack"

	// KanikoDockerImage - the default image used for Kaniko builds
	KanikoDockerImage = "gcr.io/kaniko-project/executor:v0.22.0"

	// DefaultContainerImage - the default image used for pipelines if none is specified.
	DefaultContainerImage = "gcr.io/jenkinsxio/builder-maven"
)
View Source
const (
	// GitMergeImage is the default image name that is used in the git merge step of a pipeline
	GitMergeImage = "gcr.io/jenkinsxio/builder-jx"

	// WorkingDirRoot is the root directory for working directories.
	WorkingDirRoot = "/workspace"
)

Variables

This section is empty.

Functions

func CombineEnv

func CombineEnv(newEnv []corev1.EnvVar, parentEnv []corev1.EnvVar) []corev1.EnvVar

CombineEnv combines the two environments into a single unified slice where the `newEnv` overrides anything in the `parentEnv`

func EnvMapToSlice

func EnvMapToSlice(envMap map[string]corev1.EnvVar) []corev1.EnvVar

EnvMapToSlice transforms a map of environment variables into a slice that can be used in container configuration

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)

func MergeContainers

func MergeContainers(parentContainer, childContainer *corev1.Container) (*corev1.Container, error)

MergeContainers combines parent and child container structs, with the child overriding the parent.

func PipelineRunName

func PipelineRunName(pipelineIdentifier string, buildIdentifier string) string

PipelineRunName returns the pipeline name given the pipeline and build identifier

func ReplaceCurlyWithParen

func ReplaceCurlyWithParen(input string) string

ReplaceCurlyWithParen replaces legacy "${inputs.params.foo}" with "$(inputs.params.foo)"

func StringParamValue

func StringParamValue(val string) tektonv1alpha1.ArrayOrString

StringParamValue generates a Tekton ArrayOrString value for the given string

Types

type Agent

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

	// Legacy fields from jenkinsfile.PipelineAgent
	Container string `json:"container,omitempty"`
	Dir       string `json:"dir,omitempty"`
}

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

func (*Agent) DeepCopy

func (in *Agent) DeepCopy() *Agent

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Agent.

func (*Agent) DeepCopyForParsedPipeline

func (a *Agent) DeepCopyForParsedPipeline() *Agent

DeepCopyForParsedPipeline returns a copy of the Agent with deprecated fields migrated to current ones.

func (*Agent) DeepCopyInto

func (in *Agent) DeepCopyInto(out *Agent)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*Agent) GetImage

func (a *Agent) GetImage() string

GetImage gets the agent's image to run on, opting for Image if set, then Container.

func (*Agent) Groovy

func (a *Agent) Groovy() string

Groovy returns the agent groovy expression for the agent or `any` if its blank Legacy code for Jenkinsfile generation

type CRDsFromPipelineParams

type CRDsFromPipelineParams struct {
	PipelineIdentifier string
	BuildIdentifier    string
	Namespace          string
	PodTemplates       map[string]*corev1.Pod
	VersionsDir        string
	TaskParams         []tektonv1alpha1.ParamSpec
	SourceDir          string
	Labels             map[string]string
	DefaultImage       string
	InterpretMode      bool
}

CRDsFromPipelineParams is how the parameters to GenerateCRDs are specified

func (*CRDsFromPipelineParams) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CRDsFromPipelineParams.

func (*CRDsFromPipelineParams) DeepCopyInto

func (in *CRDsFromPipelineParams) DeepCopyInto(out *CRDsFromPipelineParams)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Loop

type Loop struct {
	// The variable name.
	Variable string `json:"variable"`
	// The list of values to iterate over
	Values []string `json:"values"`
	// The steps to run
	Steps []Step `json:"steps"`
}

Loop is a special step that defines a variable, a list of possible values for that variable, and a set of steps to repeat for each value for the variable, with the variable set with that value in the environment for the execution of those steps.

func (*Loop) DeepCopy

func (in *Loop) DeepCopy() *Loop

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Loop.

func (*Loop) DeepCopyInto

func (in *Loop) DeepCopyInto(out *Loop)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type ParsedPipeline

type ParsedPipeline struct {
	Agent      *Agent          `json:"agent,omitempty"`
	Env        []corev1.EnvVar `json:"env,omitempty"`
	Options    *RootOptions    `json:"options,omitempty"`
	Stages     []Stage         `json:"stages"`
	Post       []Post          `json:"post,omitempty"`
	WorkingDir *string         `json:"dir,omitempty"`

	// Replaced by Env, retained for backwards compatibility
	Environment []corev1.EnvVar `json:"environment,omitempty"`
}

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

func ApplyNonStepOverridesToPipeline

func ApplyNonStepOverridesToPipeline(pipeline *ParsedPipeline, override *PipelineOverride) *ParsedPipeline

ApplyNonStepOverridesToPipeline applies the non-step configuration from an individual override to the pipeline.

func ApplyStepOverridesToPipeline

func ApplyStepOverridesToPipeline(pipeline *ParsedPipeline, override *PipelineOverride) *ParsedPipeline

ApplyStepOverridesToPipeline applies an individual override to the pipeline, replacing named steps in specified stages (or all stages if no stage name is specified).

func (*ParsedPipeline) AddContainerEnvVarsToPipeline

func (j *ParsedPipeline) AddContainerEnvVarsToPipeline(origEnv []corev1.EnvVar)

AddContainerEnvVarsToPipeline allows for adding a slice of container environment variables directly to the pipeline, if they're not already defined.

func (*ParsedPipeline) DeepCopy

func (in *ParsedPipeline) DeepCopy() *ParsedPipeline

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ParsedPipeline.

func (*ParsedPipeline) DeepCopyInto

func (in *ParsedPipeline) DeepCopyInto(out *ParsedPipeline)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*ParsedPipeline) GenerateCRDs

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

func (*ParsedPipeline) GetEnv

func (j *ParsedPipeline) GetEnv() []corev1.EnvVar

GetEnv gets the environment for the ParsedPipeline, returning Env first and Environment if Env isn't populated.

func (*ParsedPipeline) GetPodLabels

func (j *ParsedPipeline) GetPodLabels() map[string]string

GetPodLabels returns the optional additional labels to apply to all pods for this pipeline. The labels and their values will be converted to RFC1035-compliant strings.

func (*ParsedPipeline) GetPossibleAffinityPolicy

func (j *ParsedPipeline) GetPossibleAffinityPolicy(name string) *corev1.Affinity

GetPossibleAffinityPolicy takes the pipeline name and returns the appropriate affinity policy for pods in this pipeline given its configuration, specifically of options.distributeParallelAcrossNodes.

func (*ParsedPipeline) GetTolerations

func (j *ParsedPipeline) GetTolerations() []corev1.Toleration

GetTolerations returns the tolerations configured in the root options for this pipeline, if any.

func (*ParsedPipeline) ReplacePlaceholdersInStepAndStageDirs

func (j *ParsedPipeline) ReplacePlaceholdersInStepAndStageDirs(args StepPlaceholderReplacementArgs)

ReplacePlaceholdersInStepAndStageDirs traverses this pipeline's stages and any nested stages for any steps (and any nested steps) within the stages, and replaces "REPLACE_ME_..." placeholders in those steps' directories.

func (*ParsedPipeline) Validate

func (j *ParsedPipeline) Validate(context context.Context) *apis.FieldError

Validate checks the ParsedPipeline to find any errors in it, without validating against the cluster.

func (*ParsedPipeline) ValidateInCluster

func (j *ParsedPipeline) ValidateInCluster(context context.Context, kubeClient kubernetes.Interface, ns string) *apis.FieldError

ValidateInCluster checks the parsed ParsedPipeline to find any errors in it, including validation against the cluster.

type PipelineOverride

type PipelineOverride struct {
	Pipeline         string            `json:"pipeline,omitempty"`
	Stage            string            `json:"stage,omitempty"`
	Name             string            `json:"name,omitempty"`
	Step             *Step             `json:"step,omitempty"`
	Steps            []*Step           `json:"steps,omitempty"`
	Type             *StepOverrideType `json:"type,omitempty"`
	Agent            *Agent            `json:"agent,omitempty"`
	ContainerOptions *corev1.Container `json:"containerOptions,omitempty"`
	Volumes          []*corev1.Volume  `json:"volumes,omitempty"`
}

PipelineOverride allows for overriding named steps, stages, or pipelines in the build pack or default pipeline

func (*PipelineOverride) AsStepsSlice

func (p *PipelineOverride) AsStepsSlice() []*Step

AsStepsSlice returns a possibly empty slice of the step or steps in this override

func (*PipelineOverride) DeepCopy

func (in *PipelineOverride) DeepCopy() *PipelineOverride

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PipelineOverride.

func (*PipelineOverride) DeepCopyInto

func (in *PipelineOverride) DeepCopyInto(out *PipelineOverride)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*PipelineOverride) HasNonStepOverrides

func (p *PipelineOverride) HasNonStepOverrides() bool

HasNonStepOverrides returns true if this override contains configuration like agent, containerOptions, or volumes.

func (*PipelineOverride) MatchesPipeline

func (p *PipelineOverride) MatchesPipeline(name string) bool

MatchesPipeline returns true if the pipeline name is specified in the override or no pipeline is specified at all in the override

func (*PipelineOverride) MatchesStage

func (p *PipelineOverride) MatchesStage(name string) bool

MatchesStage returns true if the stage/lifecycle name is specified in the override or no stage/lifecycle is specified at all in the override

type Post

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

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

func (*Post) DeepCopy

func (in *Post) DeepCopy() *Post

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Post.

func (*Post) DeepCopyInto

func (in *Post) DeepCopyInto(out *Post)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type PostAction

type PostAction struct {
	// TODO: Notifications are not yet supported in Build Pipeline per se.
	Name string `json:"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 `json:"options,omitempty"`
}

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

func (*PostAction) DeepCopy

func (in *PostAction) DeepCopy() *PostAction

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PostAction.

func (*PostAction) DeepCopyInto

func (in *PostAction) DeepCopyInto(out *PostAction)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

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 `json:"timeout,omitempty"`
	Retry   int8     `json:"retry,omitempty"`
	// ContainerOptions allows for advanced configuration of containers for a single stage or the whole
	// pipeline, adding to configuration that can be configured through the syntax already. This includes things
	// like CPU/RAM requests/limits, secrets, ports, etc. Some of these things will end up with native syntax approaches
	// down the road.
	ContainerOptions              *corev1.Container   `json:"containerOptions,omitempty"`
	Volumes                       []*corev1.Volume    `json:"volumes,omitempty"`
	DistributeParallelAcrossNodes bool                `json:"distributeParallelAcrossNodes,omitempty"`
	Tolerations                   []corev1.Toleration `json:"tolerations,omitempty"`
	PodLabels                     map[string]string   `json:"podLabels,omitempty"`
}

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

func (*RootOptions) DeepCopy

func (in *RootOptions) DeepCopy() *RootOptions

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RootOptions.

func (*RootOptions) DeepCopyInto

func (in *RootOptions) DeepCopyInto(out *RootOptions)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Stage

type Stage struct {
	Name       string          `json:"name"`
	Agent      *Agent          `json:"agent,omitempty"`
	Env        []corev1.EnvVar `json:"env,omitempty"`
	Options    *StageOptions   `json:"options,omitempty"`
	Steps      []Step          `json:"steps,omitempty"`
	Stages     []Stage         `json:"stages,omitempty"`
	Parallel   []Stage         `json:"parallel,omitempty"`
	Post       []Post          `json:"post,omitempty"`
	WorkingDir *string         `json:"dir,omitempty"`

	// Replaced by Env, retained for backwards compatibility
	Environment []corev1.EnvVar `json:"environment,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.

func ApplyNonStepOverridesToStage

func ApplyNonStepOverridesToStage(stage Stage, override *PipelineOverride) Stage

ApplyNonStepOverridesToStage applies non-step overrides, such as stage agent, containerOptions, and volumes, to this stage and its children.

func ApplyStepOverridesToStage

func ApplyStepOverridesToStage(stage Stage, override *PipelineOverride) Stage

ApplyStepOverridesToStage applies a set of overrides to named steps in this stage and its children

func (*Stage) DeepCopy

func (in *Stage) DeepCopy() *Stage

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Stage.

func (*Stage) DeepCopyInto

func (in *Stage) DeepCopyInto(out *Stage)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*Stage) GetEnv

func (s *Stage) GetEnv() []corev1.EnvVar

GetEnv gets the environment for the Stage, returning Env first and Environment if Env isn't populated.

type StageOptions

type StageOptions struct {
	*RootOptions `json:",inline"`

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

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

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

func (*StageOptions) DeepCopy

func (in *StageOptions) DeepCopy() *StageOptions

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StageOptions.

func (*StageOptions) DeepCopyInto

func (in *StageOptions) DeepCopyInto(out *StageOptions)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Stash

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

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

func (*Stash) DeepCopy

func (in *Stash) DeepCopy() *Stash

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Stash.

func (*Stash) DeepCopyInto

func (in *Stash) DeepCopyInto(out *Stash)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Step

type Step struct {
	// An optional name to give the step for reporting purposes
	Name string `json:"name,omitempty"`

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

	Step string `json:"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 `json:"options,omitempty"`

	Loop *Loop `json:"loop,omitempty"`

	// agent can be overridden on a step
	Agent *Agent `json:"agent,omitempty"`

	// Image alows the docker image for a step to be specified
	Image string `json:"image,omitempty"`

	// env allows defining per-step environment variables
	Env []corev1.EnvVar `json:"env,omitempty"`

	// Legacy fields from jenkinsfile.PipelineStep before it was eliminated.
	Comment   string  `json:"comment,omitempty"`
	Groovy    string  `json:"groovy,omitempty"`
	Steps     []*Step `json:"steps,omitempty"`
	When      string  `json:"when,omitempty"`
	Container string  `json:"container,omitempty"`
	Sh        string  `json:"sh,omitempty"`
}

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

func OverrideStep

func OverrideStep(step Step, override *PipelineOverride) []Step

OverrideStep overrides an existing step, if it matches the override's name, with the contents of the override. It also recurses into child steps.

func (*Step) DeepCopy

func (in *Step) DeepCopy() *Step

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Step.

func (*Step) DeepCopyInto

func (in *Step) DeepCopyInto(out *Step)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*Step) GetCommand

func (s *Step) GetCommand() string

GetCommand gets the step's command to execute, opting for Command if set, then Sh.

func (*Step) GetFullCommand

func (s *Step) GetFullCommand() string

GetFullCommand gets the full command to execute, including arguments.

func (*Step) GetImage

func (s *Step) GetImage() string

GetImage gets the step's image to run on, opting for Image if set, then Container.

func (*Step) GroovyBlock

func (s *Step) GroovyBlock(parentIndent string) string

GroovyBlock returns the groovy expression for this step Legacy code for Jenkinsfile generation

func (*Step) PutAllEnvVars

func (s *Step) PutAllEnvVars(m map[string]string)

PutAllEnvVars puts all the defined environment variables in the given map Legacy code for Jenkinsfile generation

func (*Step) ToJenkinsfileStatements

func (s *Step) ToJenkinsfileStatements() []*util.Statement

ToJenkinsfileStatements converts the step to one or more jenkinsfile statements Legacy code for Jenkinsfile generation

func (*Step) Validate

func (s *Step) Validate() error

Validate validates the step is populated correctly Legacy code for Jenkinsfile generation

type StepOverrideType

type StepOverrideType string

StepOverrideType is used to specify whether the existing step should be replaced (default), new step(s) should be prepended before the existing step, or new step(s) should be appended after the existing step.

const (
	StepOverrideReplace StepOverrideType = "replace"
	StepOverrideBefore  StepOverrideType = "before"
	StepOverrideAfter   StepOverrideType = "after"
)

The available override types

type StepPlaceholderReplacementArgs

type StepPlaceholderReplacementArgs struct {
	WorkspaceDir      string
	GitName           string
	GitOrg            string
	GitHost           string
	DockerRegistry    string
	DockerRegistryOrg string
	ProjectID         string
	KanikoImage       string
	UseKaniko         bool
}

StepPlaceholderReplacementArgs specifies the arguments required for replacing placeholders in build pack directories.

func (*StepPlaceholderReplacementArgs) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StepPlaceholderReplacementArgs.

func (*StepPlaceholderReplacementArgs) DeepCopyInto

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Timeout

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

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

func (*Timeout) DeepCopy

func (in *Timeout) DeepCopy() *Timeout

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Timeout.

func (*Timeout) DeepCopyInto

func (in *Timeout) DeepCopyInto(out *Timeout)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*Timeout) ToDuration

func (t *Timeout) ToDuration() (*metav1.Duration, error)

ToDuration generates a duration struct from a Timeout

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 `json:"name"`
	Dir  string `json:"dir,omitempty"`
}

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

func (*Unstash) DeepCopy

func (in *Unstash) DeepCopy() *Unstash

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Unstash.

func (*Unstash) DeepCopyInto

func (in *Unstash) DeepCopyInto(out *Unstash)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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