job

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2021 License: MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// StringParameterDefinition is the definition for string parameter
	StringParameterDefinition = "StringParameterDefinition"
	// FileParameterDefinition is the definition for file parameter
	FileParameterDefinition = "FileParameterDefinition"
)

Variables

This section is empty.

Functions

func ParseJobPath

func ParseJobPath(jobName string) (path string)

ParseJobPath leads with slash

func ParsePipelinePath

func ParsePipelinePath(pipelines ...string) string

ParsePipelinePath parses multiple pipelines and leads with slash.

func PrepareEmptyItems

func PrepareEmptyItems(roundTripper *mhttp.MockRoundTripper, rootURL, name, kind, user, token string)

PrepareEmptyItems only for test

func PrepareForBuildWithNoParams

func PrepareForBuildWithNoParams(roundTripper *mhttp.MockRoundTripper, rootURL, jobName, user, password string) (
	request *http.Request, response *http.Response)

PrepareForBuildWithNoParams only for test

func PrepareForBuildWithParams

func PrepareForBuildWithParams(roundTripper *mhttp.MockRoundTripper, rootURL, jobName, user, password string) (
	request *http.Request, response *http.Response)

PrepareForBuildWithParams only for test

func PrepareForCreatePipelineJob

func PrepareForCreatePipelineJob(roundTripper *mhttp.MockRoundTripper, rootURL, user, password string, jobPayload CreateJobPayload)

PrepareForCreatePipelineJob only for test

func PrepareForDisableJob

func PrepareForDisableJob(roundTripper *mhttp.MockRoundTripper, rootURL, name, user, token string)

PrepareForDisableJob only for test

func PrepareForEnableJob

func PrepareForEnableJob(roundTripper *mhttp.MockRoundTripper, rootURL, name, user, token string)

PrepareForEnableJob only for test

func PrepareForGetBuild

func PrepareForGetBuild(roundTripper *mhttp.MockRoundTripper, rootURL, jobName string, buildID int, user, password string)

PrepareForGetBuild only for test

func PrepareForGetJob

func PrepareForGetJob(roundTripper *mhttp.MockRoundTripper, rootURL, jobName, user, password string) (
	response *http.Response)

PrepareForGetJob only for test

func PrepareForGetJobInputActions

func PrepareForGetJobInputActions(roundTripper *mhttp.MockRoundTripper, rootURL, user, password, jobName string, buildID int) (
	request *http.Request, response *http.Response)

PrepareForGetJobInputActions only for test

func PrepareForGetJobWithParams

func PrepareForGetJobWithParams(roundTripper *mhttp.MockRoundTripper, rootURL, jobName, user, password string)

PrepareForGetJobWithParams only for test

func PrepareForJobLog

func PrepareForJobLog(roundTripper *mhttp.MockRoundTripper, rootURL, jobName string, buildID int, user, password string)

PrepareForJobLog only for test

func PrepareForSubmitInput

func PrepareForSubmitInput(roundTripper *mhttp.MockRoundTripper, rootURL, jobPath, user, password string) (
	request *http.Request, response *http.Response)

PrepareForSubmitInput only for test

func PrepareForSubmitProcessInput

func PrepareForSubmitProcessInput(roundTripper *mhttp.MockRoundTripper, rootURL, jobPath, user, password string) (
	request *http.Request, response *http.Response)

PrepareForSubmitProcessInput only for test

func PrepareOneItem

func PrepareOneItem(roundTripper *mhttp.MockRoundTripper, rootURL, name, kind, user, token string)

PrepareOneItem only for test

Types

type AgentLabel

type AgentLabel struct {
	Name string
}

AgentLabel represents the label of Jenkins agent

type BlueOceanClient

type BlueOceanClient struct {
	core.JenkinsCore
	Organization string
}

BlueOceanClient is client for operating pipelines via BlueOcean RESTful API.

func (*BlueOceanClient) Build

func (boClient *BlueOceanClient) Build(organization string, pipelines ...string) (*PipelineBuild, error)

Build builds a pipeline for specific organization and pipelines.

func (*BlueOceanClient) GetBuild

func (boClient *BlueOceanClient) GetBuild(organization string, runID string, pipelines ...string) (*PipelineBuild, error)

GetBuild gets build result for specific organization, run ID and pipelines.

func (*BlueOceanClient) Search

func (boClient *BlueOceanClient) Search(name string, start, limit int) (items []JenkinsItem, err error)

Search searches jobs via the BlueOcean API

type Build

type Build struct {
	SimpleJobBuild
	Building          bool
	Description       string
	DisplayName       string
	Duration          int64
	EstimatedDuration int64
	FullDisplayName   string
	ID                string
	KeepLog           bool
	QueueID           int
	Result            string
	Timestamp         int64
	PreviousBuild     SimpleJobBuild
	NextBuild         SimpleJobBuild
}

Build represents a job build

type Category

type Category struct {
	Description string
	ID          string
	Items       []CategoryItem
	MinToShow   int
	Name        string
	Order       int
}

Category represents a job category

type CategoryItem

type CategoryItem struct {
	Description string
	DisplayName string
	Order       int
	Class       string
}

CategoryItem represents a job category item

type Client

type Client struct {
	core.JenkinsCore

	Parent string
}

Client is client for operate jobs

func (*Client) AddParameters

func (q *Client) AddParameters(name, parameters string) (err error)

AddParameters add parameters to a Pipeline

func (*Client) Build

func (q *Client) Build(jobName string) (err error)

Build trigger a job

func (*Client) BuildAndReturn

func (q *Client) BuildAndReturn(jobName, cause string, timeout, delay int) (build IdentityBuild, err error)

BuildAndReturn trigger a job then returns the build info

func (*Client) BuildWithParams

func (q *Client) BuildWithParams(jobName string, parameters []ParameterDefinition) (err error)

BuildWithParams build a job which has params

func (*Client) Create

func (q *Client) Create(jobPayload CreateJobPayload) (err error)

Create can create a job

func (*Client) CreateJobInFolder

func (q *Client) CreateJobInFolder(jobPayload CreateJobPayload, path string) (err error)

CreateJobInFolder creates a job in a specific folder and create folder first if the folder does not exist

func (*Client) Delete

func (q *Client) Delete(jobName string) (err error)

Delete will delete a job by name

func (*Client) DeleteHistory

func (q *Client) DeleteHistory(jobName string, num int) (err error)

DeleteHistory returns the build history of a job

func (*Client) DisableJob

func (q *Client) DisableJob(jobName string) (err error)

DisableJob disable a job

func (*Client) EnableJob

func (q *Client) EnableJob(jobName string) (err error)

EnableJob disable a job

func (*Client) GetBuild

func (q *Client) GetBuild(jobName string, id int) (job *Build, err error)

GetBuild get build information of a job

func (*Client) GetHistory

func (q *Client) GetHistory(name string) (builds []*Build, err error)

GetHistory returns the build history of a job

func (*Client) GetJob

func (q *Client) GetJob(name string) (job *Job, err error)

GetJob returns the job info

func (*Client) GetJobInputActions

func (q *Client) GetJobInputActions(jobName string, buildID int) (actions []InputItem, err error)

GetJobInputActions returns the all pending actions

func (*Client) GetJobTypeCategories

func (q *Client) GetJobTypeCategories() (jobCategories []Category, err error)

GetJobTypeCategories returns all categories of jobs

func (*Client) GetPipeline

func (q *Client) GetPipeline(name string) (pipeline *Pipeline, err error)

GetPipeline return the pipeline object

func (*Client) JobInputSubmit

func (q *Client) JobInputSubmit(jobName, inputID string, buildID int, abort bool, params map[string]string) (err error)

JobInputSubmit submit the pending input request

func (*Client) Log

func (q *Client) Log(jobName string, history int, start int64) (jobLog Log, err error)

Log get the log of a job

func (*Client) RemoveParameters

func (q *Client) RemoveParameters(name, parameters string) (err error)

RemoveParameters add parameters to a Pipeline

func (*Client) Search

func (q *Client) Search(name, kind string, start, limit int) (items []JenkinsItem, err error)

Search find a set of jobs by name

func (*Client) SearchViaBlue deprecated

func (q *Client) SearchViaBlue(name string, start, limit int) (items []JenkinsItem, err error)

SearchViaBlue searches jobs via the BlueOcean API

Deprecated: For clearer client of BlueOcean, please use BlueOceanClient#Search instead

func (*Client) StopJob

func (q *Client) StopJob(jobName string, num int) (err error)

StopJob stops a job build

func (*Client) UpdatePipeline

func (q *Client) UpdatePipeline(name, script string) (err error)

UpdatePipeline updates the pipeline script

type CreateJobPayload

type CreateJobPayload struct {
	Name string `json:"name"`
	Mode string `json:"mode"`
	From string `json:"from"`
}

CreateJobPayload the payload for creating a job

type DefaultParameterValue

type DefaultParameterValue struct {
	Description string
	Value       interface{}
}

DefaultParameterValue represents the default value for param

type IdentityBuild

type IdentityBuild struct {
	Build Build
	Cause IdentityCause
}

IdentityBuild is the build which carry the identity cause

type IdentityCause

type IdentityCause struct {
	UUID             string `json:"uuid"`
	ShortDescription string `json:"shortDescription"`
	Message          string
}

IdentityCause carray a identity cause

type InputItem

type InputItem struct {
	ID                  string
	AbortURL            string
	Message             string
	ProceedText         string
	ProceedURL          string
	RedirectApprovalURL string
	Inputs              []ParameterDefinition
}

InputItem represents a job input action

type JenkinsInputParametersRequest

type JenkinsInputParametersRequest struct {
	Parameter []ParameterDefinition `json:"parameter"`
}

JenkinsInputParametersRequest represents the parameters for the Jenkins input request

type JenkinsItem

type JenkinsItem struct {
	Name        string
	DisplayName string
	URL         string
	Description string
	Type        string

	/** comes from Job */
	Buildable bool
	Building  bool
	InQueue   bool

	/** comes from ParameterizedJob */
	Parameterized bool
	Disabled      bool

	/** comes from blueOcean */
	FullName     string
	WeatherScore int
	Parameters   []ParameterDefinition
}

JenkinsItem represents the item of Jenkins

type JenkinsStatus

type JenkinsStatus struct {
	AssignedLabels  []AgentLabel
	Description     string
	Jobs            []Job
	Mode            string
	NodeDescription string
	NodeName        string
	NumExecutors    int
	PrimaryView     View
	QuietingDown    bool
	SlaveAgentPort  int
	UseCrumbs       bool
	UseSecurity     bool
	Views           []View
	Version         string
}

JenkinsStatus holds the status of Jenkins

type JenkinsStatusClient

type JenkinsStatusClient struct {
	core.JenkinsCore
}

JenkinsStatusClient use to connect with Jenkins status

func (*JenkinsStatusClient) Get

func (q *JenkinsStatusClient) Get() (status *JenkinsStatus, err error)

Get returns status of Jenkins

type Job

type Job struct {
	Type            string `json:"_class"`
	Builds          []Build
	Color           string
	ConcurrentBuild bool
	Name            string
	NextBuildNumber int
	URL             string
	Buildable       bool

	Property []ParametersDefinitionProperty
}

Job represents a job

type Log

type Log struct {
	HasMore   bool
	NextStart int64
	Text      string
}

Log holds the log text

type ParameterDefinition

type ParameterDefinition struct {
	Description           string
	Name                  string `json:"name"`
	Type                  string
	Value                 string `json:"value"`
	Filepath              string `json:"file"`
	DefaultParameterValue DefaultParameterValue
}

ParameterDefinition holds the parameter definition

type ParametersDefinitionProperty

type ParametersDefinitionProperty struct {
	ParameterDefinitions []ParameterDefinition
}

ParametersDefinitionProperty holds the param definition property

type Pipeline

type Pipeline struct {
	Script  string
	Sandbox bool
}

Pipeline represents a pipeline

type PipelineBuild

type PipelineBuild struct {
	Actions                   []interface{} `json:"actions,omitempty" description:"the list of all actions"`
	ArtifactsZipFile          interface{}   `json:"artifactsZipFile,omitempty" description:"the artifacts zip file"`
	CauseOfBlockage           string        `json:"causeOfBlockage,omitempty" description:"the cause of blockage"`
	Causes                    []interface{} `json:"causes,omitempty"`
	ChangeSet                 []interface{} `json:"changeSet,omitempty" description:"changeset information"`
	Description               interface{}   `json:"description,omitempty" description:"description"`
	DurationInMillis          interface{}   `json:"durationInMillis,omitempty" description:"duration time in millis"`
	EnQueueTime               Time          `json:"enQueueTime,omitempty" description:"the time of enter the queue"`
	EndTime                   Time          `json:"endTime,omitempty" description:"the time of end"`
	EstimatedDurationInMillis interface{}   `json:"estimatedDurationInMillis,omitempty" description:"estimated duration time in millis"`
	ID                        string        `json:"id,omitempty" description:"id"`
	Name                      interface{}   `json:"name,omitempty" description:"name"`
	Organization              string        `json:"organization,omitempty" description:"the name of organization"`
	Pipeline                  string        `json:"pipeline,omitempty" description:"pipeline"`
	Replayable                bool          `json:"replayable,omitempty" description:"replayable or not"`
	Result                    string        `json:"result,omitempty" description:"the result of pipeline run. e.g. SUCCESS"`
	RunSummary                interface{}   `json:"runSummary,omitempty" description:"pipeline run summary"`
	StartTime                 Time          `json:"startTime,omitempty" description:"the time of start"`
	State                     string        `json:"state,omitempty" description:"run state. e.g. RUNNING"`
	Type                      string        `json:"type,omitempty" description:"type"`
	QueueID                   string        `json:"queueId,omitempty" description:"queue id"`
}

PipelineBuild represents a build detail of Pipeline.

type SimpleJobBuild

type SimpleJobBuild struct {
	Number int
	URL    string
}

SimpleJobBuild represents a simple job build

type Time

type Time struct {
	time.Time
}

Time wraps time.Time for more flexible operations.

func (*Time) IsZero

func (t *Time) IsZero() bool

IsZero returns the true if the value is nil or time is zero.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json Unmarshaler interface.

type View

type View struct {
	Name string
	URL  string
}

View represents the view of Jenkins

Jump to

Keyboard shortcuts

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