jenkins

package
v0.0.0-...-254719a Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2022 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NodeModeNormal sets node usage as "Use this node as much as possible"
	NodeModeNormal NodeMode = "NORMAL"
	// NodeModeExclusive sets node usage as "Only build jobs with label expressions matching this node"
	NodeModeExclusive NodeMode = "EXCLUSIVE"

	// NodesCreateURL is the URL to create a new node
	NodesCreateURL = "/computer/doCreateItem"
	// NodesListURL is the URL to list all nodes
	NodesListURL = "/computer/api/json"
	// NodesGetURL is the URL to get a node
	NodesGetURL = "/computer/%s/config.xml"
	// NodesDeleteURL is the URL to delete a node
	NodesDeleteURL = "/computer/%s/doDelete"
)

Variables

This section is empty.

Functions

func DefaultHTTPClient

func DefaultHTTPClient() *http.Client

DefaultHTTPClient returns a default http client.

Types

type AssignedLabels

type AssignedLabels struct {
	Name string `json:"name"`
}

AssignedLabels represents a Jenkins assigned labels.

type BasicAuthTransport

type BasicAuthTransport struct {
	Username string
	Password string
}

BasicAuthTransport is a http.RoundTripper that authenticates all requests

func (BasicAuthTransport) RoundTrip

func (t BasicAuthTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the RoundTripper interface.

type Client

type Client struct {
	UserAgent string

	Nodes *NodesService
	// contains filtered or unexported fields
}

A Client manages communication with the Jenkins API.

func NewClient

func NewClient(opts ...ClientOption) (*Client, error)

NewClient returns a new Jenkins API client.

type ClientOption

type ClientOption func(*Client) error

ClientOption represents an option for the Jenkins client.

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL sets the base URL for the Jenkins client.

func WithClient

func WithClient(client *http.Client) ClientOption

WithClient sets the http client for the Jenkins client.

func WithUserPassword

func WithUserPassword(userName, password string) ClientOption

WithUserPassword sets the password for the Jenkins client.

func WithUserToken

func WithUserToken(userName, apiToken string) ClientOption

WithUserToken sets the API token for the Jenkins client.

type ClockMonitor

type ClockMonitor struct {
	Class string `json:"_class"`
	Diff  int    `json:"diff"`
}

ClockMonitor checks clock of a node to detect out of sync clocks.

type Computer

type Computer struct {
	Class               string           `json:"_class"`
	Actions             []interface{}    `json:"actions"`
	AssignedLabels      []AssignedLabels `json:"assignedLabels"`
	Description         string           `json:"description"`
	DisplayName         string           `json:"displayName"`
	Executors           []Executors      `json:"executors"`
	Icon                string           `json:"icon"`
	IconClassName       string           `json:"iconClassName"`
	Idle                bool             `json:"idle"`
	JnlpAgent           bool             `json:"jnlpAgent"`
	LaunchSupported     bool             `json:"launchSupported"`
	LoadStatistics      LoadStatistics   `json:"loadStatistics"`
	ManualLaunchAllowed bool             `json:"manualLaunchAllowed"`
	MonitorData         MonitorData      `json:"monitorData"`
	NumExecutors        int              `json:"numExecutors"`
	Offline             bool             `json:"offline"`
	OfflineCause        interface{}      `json:"offlineCause"`
	OfflineCauseReason  string           `json:"offlineCauseReason"`
	OneOffExecutors     []interface{}    `json:"oneOffExecutors"`
	TemporarilyOffline  bool             `json:"temporarilyOffline"`
	AbsoluteRemotePath  interface{}      `json:"absoluteRemotePath,omitempty"`
}

Computer represents a Jenkins node/agent.

type Crumbs

type Crumbs struct {
	Value        string `json:"crumb"`
	RequestField string `json:"crumbRequestField"`
}

Crumbs represents Jenkins CSRF Crumbs

type DiskSpaceMonitor

type DiskSpaceMonitor struct {
	Class     string `json:"_class"`
	Timestamp int64  `json:"timestamp"`
	Path      string `json:"path"`
	Size      int64  `json:"size"`
}

DiskSpaceMonitor checks available disk space of the remote FS root.

type Executors

type Executors struct {
}

Executors represents a Jenkins executors.

type JNLPLauncher

type JNLPLauncher struct {
	StaplerClass string `json:"stapler-class" xml:"class,attr"`

	WebSocket       bool            `json:"websocket" xml:"websocket,omitempty"`
	WorkDirSettings WorkDirSettings `json:"workDirSettings,omitempty" xml:"workDirSettings,omitempty"`
}

JNLPLauncher represents a Jenkins JNLP launcher.

func DefaultJNLPLauncher

func DefaultJNLPLauncher() *JNLPLauncher

DefaultJNLPLauncher returns the default JNLP launcher.

type KnownHostsFileKeyVerificationStrategy

type KnownHostsFileKeyVerificationStrategy struct {
	StaplerClass string `json:"stapler-class" xml:"class,attr"`
}

KnownHostsFileKeyVerificationStrategy represents the Jenkins node known hosts file key verification strategy.

type Labels

type Labels []string

Labels represents Jenkins node labels.

func (Labels) MarshalJSON

func (l Labels) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface. Concatenates all labels with a space.

type Launcher

type Launcher interface{}

Launcher is the interface for all Jenkins node launchers.

type LoadStatistics

type LoadStatistics struct {
	Class string `json:"_class"`
}

LoadStatistics represents a Jenkins load statistics.

type ManuallyProvidedKeyVerificationStrategy

type ManuallyProvidedKeyVerificationStrategy struct {
	StaplerClass string `json:"stapler-class" xml:"class,attr"`

	Key ManuallyProvidedKeyVerificationStrategyKey `json:"key" xml:"key"`
}

ManuallyProvidedKeyVerificationStrategy represents the Jenkins node manually provided key verification strategy.

type ManuallyProvidedKeyVerificationStrategyKey

type ManuallyProvidedKeyVerificationStrategyKey struct {
	Algorithm string `json:"algorithm" xml:"algorithm"`
	Key       string `json:"key" xml:"key"`
}

ManuallyProvidedKeyVerificationStrategyKey represents the Jenkins node manually provided key verification strategy key.

type ManuallyTrustedKeyVerificationStrategy

type ManuallyTrustedKeyVerificationStrategy struct {
	StaplerClass string `json:"stapler-class" xml:"class,attr"`

	RequireInitialManualTrust bool `json:"requireInitialManualTrust,omitempty" xml:"requireInitialManualTrust,omitempty"`
}

ManuallyTrustedKeyVerificationStrategy represents the Jenkins node manually trusted key verification strategy.

type MonitorData

type MonitorData struct {
	SwapSpaceMonitor      SwapSpaceMonitor      `json:"hudson.node_monitors.SwapSpaceMonitor"`
	TemporarySpaceMonitor TemporarySpaceMonitor `json:"hudson.node_monitors.TemporarySpaceMonitor"`
	DiskSpaceMonitor      DiskSpaceMonitor      `json:"hudson.node_monitors.DiskSpaceMonitor"`
	ArchitectureMonitor   string                `json:"hudson.node_monitors.ArchitectureMonitor"`
	ResponseTimeMonitor   ResponseTimeMonitor   `json:"hudson.node_monitors.ResponseTimeMonitor"`
	ClockMonitor          ClockMonitor          `json:"hudson.node_monitors.ClockMonitor"`
}

MonitorData expose monitoring data

type Node

type Node struct {
	XMLName xml.Name `xml:"slave" json:"-"`

	Name               string              `json:"name" xml:"name"`
	Description        string              `json:"nodeDescription" xml:"description"`
	RemoteFS           string              `json:"remoteFS" xml:"remoteFS"`
	NumExecutors       int                 `json:"numExecutors" xml:"numExecutors"`
	Mode               NodeMode            `json:"mode" xml:"mode"`
	Type               NodeType            `json:"type" xml:"type"`
	Labels             Labels              `json:"labelString" xml:"label"`
	RetentionsStrategy *RetentionsStrategy `json:"retentionsStrategy" xml:"retentionsStrategy"`
	Properties         *NodeProperties     `json:"nodeProperties" xml:"nodeProperties"`
	Launcher           Launcher            `json:"launcher" xml:"launcher"`
}

Node represents a Jenkins node.

func (*Node) UnmarshalXML

func (n *Node) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements the xml.Unmarshaler interface. It decodes the XML attributes into the corresponding struct fields. It also decodes the XML child Launcher nodes into the corresponding struct fields.

type NodeMode

type NodeMode string

NodeMode represents a Jenkins node mode. Could be either NORMAL or EXCLUSIVE.

type NodeProperties

type NodeProperties struct {
	StaplerClassBag string `json:"stapler-class-bag"`
}

NodeProperties represents a Jenkins node properties.

func DefaultNodeProperties

func DefaultNodeProperties() *NodeProperties

DefaultNodeProperties returns the default node properties.

type NodeRequest

type NodeRequest struct {
	Name string   `json:"name"`
	Type NodeType `json:"type"`
	JSON string   `json:"json"`
}

NodeRequest represents a Jenkins node request.

type NodeType

type NodeType string

NodeType represents a Jenkins node type.

func DefaultNodeType

func DefaultNodeType() NodeType

DefaultNodeType represents the default Jenkins node type.

type NodesListResponse

type NodesListResponse struct {
	Class          string     `json:"_class"`
	BusyExecutors  int        `json:"busyExecutors"`
	Computer       []Computer `json:"computer"`
	DisplayName    string     `json:"displayName"`
	TotalExecutors int        `json:"totalExecutors"`
}

NodesListResponse represents a Jenkins node list response.

type NodesService

type NodesService service

NodesService handles communication with the node related methods of the Jenkins API

func (*NodesService) Create

func (s *NodesService) Create(ctx context.Context, node *Node) (*Node, *http.Response, error)

Create creates a new Jenkins node.

func (*NodesService) Delete

func (s *NodesService) Delete(ctx context.Context, name string) (*http.Response, error)

Delete deletes a Jenkins node.

func (*NodesService) Get

func (s *NodesService) Get(ctx context.Context, name string) (*Node, *http.Response, error)

Get returns a Jenkins node.

func (*NodesService) List

func (s *NodesService) List(ctx context.Context) ([]Node, *http.Response, error)

List returns a list of Jenkins nodes.

func (*NodesService) Update

func (s *NodesService) Update(ctx context.Context, node *Node) (*Node, *http.Response, error)

Update updates a Jenkins node.

type NonVerifyingKeyVerificationStrategy

type NonVerifyingKeyVerificationStrategy struct {
	StaplerClass string `json:"stapler-class" xml:"class,attr"`
}

NonVerifyingKeyVerificationStrategy represents the Jenkins node non-verifying key verification strategy.

func NewNonVerifyingKeyVerificationStrategy

func NewNonVerifyingKeyVerificationStrategy() *NonVerifyingKeyVerificationStrategy

type ResponseTimeMonitor

type ResponseTimeMonitor struct {
	Class     string `json:"_class"`
	Timestamp int64  `json:"timestamp"`
	Average   int    `json:"average"`
}

ResponseTimeMonitor monitors the round-trip response time to this agent.

type RetentionsStrategy

type RetentionsStrategy struct {
	StaplerClass string `json:"stapler-class" xml:"class,attr"`
}

RetentionsStrategy represents a Jenkins node retention strategy.

func DefaultRetentionsStrategy

func DefaultRetentionsStrategy() *RetentionsStrategy

DefaultRetentionsStrategy represents the default retention strategy.

type SSHHostKeyVerificationStrategy

type SSHHostKeyVerificationStrategy interface{}

SSHHostKeyVerificationStrategy represents the Jenkins node SSH host key verification strategy.

type SSHLauncher

type SSHLauncher struct {
	StaplerClass string `json:"stapler-class" xml:"class,attr"`

	Host                 string `json:"host" xml:"host"`
	Port                 int    `json:"port" xml:"port"`
	CredentialID         string `json:"credentialId" xml:"credentialId"`
	LaunchTimeoutSeconds int    `json:"launchTimeoutSeconds" xml:"launchTimeoutSeconds"`
	MaxNumRetries        int    `json:"maxNumRetries" xml:"maxNumRetries"`
	RetryWaitTime        int    `json:"retryWaitTime" xml:"retryWaitTime"`
	TCPNoDelay           bool   `json:"tcpNoDelay" xml:"tcpNoDelay"`

	SSHHostKeyVerificationStrategy SSHHostKeyVerificationStrategy `json:"sshHostKeyVerificationStrategy" xml:"sshHostKeyVerificationStrategy"`
}

SSHLauncher represents a Jenkins SSH launcher.

func NewSSHLauncher

func NewSSHLauncher(host string, port int, credentialID string, launchTimeoutSeconds int, maxNumRetries int, retryWaitTime int, TCPNoDelay bool, SSHHostKeyVerificationStrategy interface{}) *SSHLauncher

func (*SSHLauncher) UnmarshalXML

func (n *SSHLauncher) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements the xml.Unmarshaler interface. It decodes the XML attributes into the corresponding struct fields. It also decodes the XML child SSHHostKeyVerificationStrategy nodes into the corresponding struct fields.

type SwapSpaceMonitor

type SwapSpaceMonitor struct {
	Class                   string `json:"_class"`
	AvailablePhysicalMemory int64  `json:"availablePhysicalMemory"`
	AvailableSwapSpace      int    `json:"availableSwapSpace"`
	TotalPhysicalMemory     int64  `json:"totalPhysicalMemory"`
	TotalSwapSpace          int    `json:"totalSwapSpace"`
}

SwapSpaceMonitor checks the swap space availability.

type TemporarySpaceMonitor

type TemporarySpaceMonitor struct {
	Class     string `json:"_class"`
	Timestamp int64  `json:"timestamp"`
	Path      string `json:"path"`
	Size      int64  `json:"size"`
}

TemporarySpaceMonitor monitors the disk space of "/tmp".

type WorkDirSettings

type WorkDirSettings struct {
	Disabled               bool   `json:"disabled" xml:"disabled"`
	InternalDir            string `json:"internalDir" xml:"internalDir"`
	FailIfWorkDirIsMissing bool   `json:"failIfWorkDirIsMissing" xml:"failIfWorkDirIsMissing"`
}

WorkDirSettings represents the Jenkins node work directory settings.

Jump to

Keyboard shortcuts

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