jenkinsutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2020 License: Apache-2.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// TriggerJenkinsServerEnv the environment variable used to choose the jenkins server to trigger
	TriggerJenkinsServerEnv = "TRIGGER_JENKINS_SERVER"

	// JenkinsSelector the default selector to find Jenkins services as Kubernetes Services
	JenkinsSelector = "app=jenkins-operator"

	// JenkinsNameLabel default label to indicate the name of the Jenkins service
	JenkinsNameLabel = "jenkins-cr"
)

Variables

View Source
var (
	// DefaultJenkinsSelector default selector options to use if finding Jenkins services
	DefaultJenkinsSelector = JenkinsSelectorOptions{
		Selector:  JenkinsSelector,
		NameLabel: JenkinsNameLabel,
	}
)

Functions

func FindJenkinsServers

func FindJenkinsServers(f *ClientFactory, jenkinsSelector *JenkinsSelectorOptions) (map[string]*JenkinsServer, []string, error)

FindJenkinsServers discovers the jenkins services

func PopulateAuth

func PopulateAuth(secret *v1.Secret) *gojenkins.Auth

PopulateAuth populates the gojenkins Auth

Types

type ClientFactory

type ClientFactory struct {
	KubeClient            kubernetes.Interface
	Namespace             string
	Batch                 bool
	InCluster             bool
	DevelopmentJenkinsURL string
}

func (*ClientFactory) CreateJenkinsClient

func (f *ClientFactory) CreateJenkinsClient(jenkinsName string) (gojenkins.JenkinsClient, error)

CreateJenkinsClient creates a new Jenkins client for the given custom Jenkins App

func (*ClientFactory) JenkinsURL

func (f *ClientFactory) JenkinsURL(jenkinsServiceName string) (string, error)

JenkinsURL gets a given jenkins service's URL

type JenkinsOptions

type JenkinsOptions struct {
	ClientFactory *ClientFactory

	BatchMode     bool
	IOFileHandles *util.IOFileHandles
	// contains filtered or unexported fields
}

func (*JenkinsOptions) AddJenkinsJobs

func (o *JenkinsOptions) AddJenkinsJobs(jenkins gojenkins.JenkinsClient, jobMap *map[string]gojenkins.Job, filter string, prefix string, jobs []gojenkins.Job)

AddJenkinsJobs add the given jobs to Jenkins

func (*JenkinsOptions) CreateJenkinsClientFromSelector

func (o *JenkinsOptions) CreateJenkinsClientFromSelector(jenkinsSelector *JenkinsSelectorOptions) (gojenkins.JenkinsClient, error)

CreateJenkinsClientFromSelector is given either a specific jenkins service name to use, uses the selector to find it or prompts the user to pick one if not in batch mode.

func (*JenkinsOptions) FindGitInfo

func (o *JenkinsOptions) FindGitInfo(dir string) (*gits.GitRepository, error)

FindGitInfo parses the git information from the given directory

func (*JenkinsOptions) GetAllPipelineJobNames

func (o *JenkinsOptions) GetAllPipelineJobNames(jenkinsClient gojenkins.JenkinsClient, jobNames *[]string, jobName string) error

GetAllPipelineJobNames returns all the pipeline job names

func (*JenkinsOptions) GetBranchName

func (o *JenkinsOptions) GetBranchName(dir string) string

func (*JenkinsOptions) GetIOFileHandles

func (o *JenkinsOptions) GetIOFileHandles() util.IOFileHandles

GetIOFileHandles returns In, Out, and Err as an IOFileHandles struct

func (*JenkinsOptions) GetJenkinsJobName

func (o *JenkinsOptions) GetJenkinsJobName() string

GetJenkinsJobName returns the Jenkins job name

func (*JenkinsOptions) GetJenkinsJobs

func (o *JenkinsOptions) GetJenkinsJobs(jenkinsSelector *JenkinsSelectorOptions, filter string) (map[string]gojenkins.Job, error)

GetJenkinsJobs returns the existing Jenkins jobs

func (*JenkinsOptions) Git

func (o *JenkinsOptions) Git() gits.Gitter

Git returns the git client

func (*JenkinsOptions) PickCustomJenkinsName

func (o *JenkinsOptions) PickCustomJenkinsName(jenkinsSelector *JenkinsSelectorOptions, failIfNone bool) (string, *JenkinsServer, error)

PickCustomJenkinsName picks the name of a custom jenkins server App if available

func (*JenkinsOptions) SetGit

func (o *JenkinsOptions) SetGit(git gits.Gitter)

SetGit sets the git client

func (*JenkinsOptions) TailJenkinsBuildLog

func (o *JenkinsOptions) TailJenkinsBuildLog(jenkinsSelector *JenkinsSelectorOptions, jobName string, build *gojenkins.Build) error

TailJenkinsBuildLog tail the build log of the given Jenkins jobs name

type JenkinsSelectorOptions

type JenkinsSelectorOptions struct {
	// JenkinsName the name of the Jenkins Operator Service for HTTP to use
	JenkinsName string

	// Selector label selector to find the Jenkins Operator Services
	Selector string

	// NameLabel label the label to find the name of the Jenkins service
	NameLabel string

	// DevelopmentJenkinsURL a local URL to use to talk to the jenkins server if the servers do not have Ingress
	// and you want to test out using the jenkins client locally
	DevelopmentJenkinsURL string
}

JenkinsSelectorOptions used to represent the options used to refer to a Jenkins. if nothing is specified it assumes the current team is using a static Jenkins server as its execution engine. otherwise we can refer to other additional Jenkins Apps to implement custom Jenkins servers

func (*JenkinsSelectorOptions) AddFlags

func (o *JenkinsSelectorOptions) AddFlags(cmd *cobra.Command)

AddFlags add the command flags for picking a custom Jenkins App to work with

type JenkinsServer

type JenkinsServer struct {
	// Name the name of the Jenkins server in the registry. Should be a valid kubernetes name
	Name string

	// URL the URL to connect to the Jenkins server
	URL string

	// SecretName the name of the Secret in the registry
	SecretName string

	// Auth the username and token used to access the Jenkins server
	Auth gojenkins.Auth
}

JenkinsServer represents a jenkins server discovered via Service selectors or via the trigger-pipeline secrets

func (*JenkinsServer) CreateClient

func (j *JenkinsServer) CreateClient() (gojenkins.JenkinsClient, error)

CreateClient creates a Jenkins client for a jenkins service

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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