Documentation
¶
Overview ¶
Gojenkins is a Jenkins Client in Go, that exposes the jenkins REST api in a more developer friendly way.
Index ¶
- Constants
- Variables
- type APIRequest
- type APIToken
- type APITokenGenerateResponse
- type Artifact
- type BasicAuth
- type Build
- func (b *Build) GetActions() []generalObj
- func (b *Build) GetAllFingerPrints(ctx context.Context) []*FingerPrint
- func (b *Build) GetArtifacts() []Artifact
- func (b *Build) GetBuildNumber() int64
- func (b *Build) GetCauses(ctx context.Context) ([]map[string]interface{}, error)
- func (b *Build) GetConsoleOutput(ctx context.Context) string
- func (b *Build) GetConsoleOutputFromIndex(ctx context.Context, startID int64) (consoleResponse, error)
- func (b *Build) GetCulprits() []Culprit
- func (b *Build) GetDownstreamBuilds(ctx context.Context) ([]*Build, error)
- func (b *Build) GetDownstreamJobNames(ctx context.Context) []string
- func (b *Build) GetDuration() float64
- func (b *Build) GetInjectedEnvVars(ctx context.Context) (map[string]string, error)
- func (b *Build) GetMatrixRuns(ctx context.Context) ([]*Build, error)
- func (b *Build) GetParameters() []parameter
- func (b *Build) GetResult() string
- func (b *Build) GetResultSet(ctx context.Context) (*TestResult, error)
- func (b *Build) GetRevision() string
- func (b *Build) GetRevisionBranch() (string, error)
- func (b *Build) GetTimestamp() time.Time
- func (b *Build) GetUpstreamBuild(ctx context.Context) (*Build, error)
- func (b *Build) GetUpstreamBuildNumber(ctx context.Context) (int64, error)
- func (b *Build) GetUpstreamJob(ctx context.Context) (*Job, error)
- func (b *Build) GetUrl() string
- func (b *Build) Info() *BuildResponse
- func (b *Build) IsGood(ctx context.Context) bool
- func (b *Build) IsRunning(ctx context.Context) bool
- func (b *Build) Poll(ctx context.Context, options ...interface{}) (int, error)
- func (b *Build) SetDescription(ctx context.Context, description string) error
- func (b *Build) Stop(ctx context.Context) (bool, error)
- type BuildResponse
- type BuildRevision
- type Builds
- type Computers
- type CredentialsManager
- func (cm CredentialsManager) Add(ctx context.Context, domain string, creds interface{}) error
- func (cm CredentialsManager) Delete(ctx context.Context, domain string, id string) error
- func (cm CredentialsManager) GetSingle(ctx context.Context, domain string, id string, creds interface{}) error
- func (cm CredentialsManager) List(ctx context.Context, domain string) ([]string, error)
- func (cm CredentialsManager) Update(ctx context.Context, domain string, id string, creds interface{}) error
- type Culprit
- type DockerServerCredentials
- type ErrAPIToken
- type ErrUser
- type Executor
- type ExecutorResponse
- type FileCredentials
- type FingerPrint
- func (f FingerPrint) GetInfo(ctx context.Context) (*FingerPrintResponse, error)
- func (f FingerPrint) Poll(ctx context.Context) (int, error)
- func (f FingerPrint) Valid(ctx context.Context) (bool, error)
- func (f FingerPrint) ValidateForBuild(ctx context.Context, filename string, build *Build) (bool, error)
- type FingerPrintResponse
- type Folder
- type FolderResponse
- type History
- type InnerJob
- type Jenkins
- func (j *Jenkins) BuildJob(ctx context.Context, name string, params map[string]string) (int64, error)
- func (j *Jenkins) CopyJob(ctx context.Context, copyFrom string, newName string) (*Job, error)
- func (j *Jenkins) CreateFolder(ctx context.Context, name string, parents ...string) (*Folder, error)
- func (j *Jenkins) CreateJob(ctx context.Context, config string, options ...interface{}) (*Job, error)
- func (j *Jenkins) CreateJobInFolder(ctx context.Context, config string, jobName string, parentIDs ...string) (*Job, error)
- func (j *Jenkins) CreateNode(ctx context.Context, name string, numExecutors int, description string, ...) (*Node, error)
- func (j *Jenkins) CreateUser(ctx context.Context, userName, password, fullName, email string) (User, error)
- func (j *Jenkins) CreateView(ctx context.Context, name string, viewType string) (*View, error)
- func (j *Jenkins) DeleteJob(ctx context.Context, name string) (bool, error)
- func (j *Jenkins) DeleteNode(ctx context.Context, name string) (bool, error)
- func (j *Jenkins) DeleteUser(ctx context.Context, userName string) error
- func (j *Jenkins) GenerateAPIToken(ctx context.Context, tokenName string) (APIToken, error)
- func (j *Jenkins) GetAllBuildIds(ctx context.Context, job string) ([]JobBuild, error)
- func (j *Jenkins) GetAllJobNames(ctx context.Context) ([]InnerJob, error)
- func (j *Jenkins) GetAllJobs(ctx context.Context) ([]*Job, error)
- func (j *Jenkins) GetAllNodes(ctx context.Context) ([]*Node, error)
- func (j *Jenkins) GetAllViews(ctx context.Context) ([]*View, error)
- func (j *Jenkins) GetArtifactData(ctx context.Context, id string) (*FingerPrintResponse, error)
- func (j *Jenkins) GetBuild(ctx context.Context, jobName string, number int64) (*Build, error)
- func (j *Jenkins) GetBuildFromQueueID(ctx context.Context, job *Job, queueid int64) (*Build, error)
- func (j *Jenkins) GetFolder(ctx context.Context, id string, parents ...string) (*Folder, error)
- func (j *Jenkins) GetJob(ctx context.Context, id string, parentIDs ...string) (*Job, error)
- func (j *Jenkins) GetJobObj(ctx context.Context, name string) *Job
- func (j *Jenkins) GetLabel(ctx context.Context, name string) (*Label, error)
- func (j *Jenkins) GetNode(ctx context.Context, name string) (*Node, error)
- func (j *Jenkins) GetPlugins(ctx context.Context, depth int) (*Plugins, error)
- func (j *Jenkins) GetQueue(ctx context.Context) (*Queue, error)
- func (j *Jenkins) GetQueueItem(ctx context.Context, id int64) (*Task, error)
- func (j *Jenkins) GetQueueUrl() string
- func (j *Jenkins) GetSubJob(ctx context.Context, parentId string, childId string) (*Job, error)
- func (j *Jenkins) GetView(ctx context.Context, name string) (*View, error)
- func (j *Jenkins) HasPlugin(ctx context.Context, name string) (*Plugin, error)
- func (j *Jenkins) Info(ctx context.Context) (*ExecutorResponse, error)
- func (j *Jenkins) Init(ctx context.Context) (*Jenkins, error)
- func (j *Jenkins) InstallPlugin(ctx context.Context, name string, version string) error
- func (j *Jenkins) Poll(ctx context.Context) (int, error)
- func (j *Jenkins) RenameJob(ctx context.Context, job string, name string) *Job
- func (j *Jenkins) RevokeAPIToken(ctx context.Context, tokenUuid string) error
- func (j *Jenkins) RevokeAllAPITokens(ctx context.Context) error
- func (j *Jenkins) SafeRestart(ctx context.Context) error
- func (j *Jenkins) UninstallPlugin(ctx context.Context, name string) error
- func (j *Jenkins) UpdateJob(ctx context.Context, job string, config string) *Job
- func (j *Jenkins) ValidateFingerPrint(ctx context.Context, id string) (bool, error)
- type JenkinsRequester
- type Job
- func (j *Job) Copy(ctx context.Context, destinationName string) (*Job, error)
- func (j *Job) Create(ctx context.Context, config string, qr ...interface{}) (*Job, error)
- func (j *Job) Delete(ctx context.Context) (bool, error)
- func (j *Job) Disable(ctx context.Context) (bool, error)
- func (j *Job) Enable(ctx context.Context) (bool, error)
- func (j *Job) GetAllBuildIds(ctx context.Context) ([]JobBuild, error)
- func (j *Job) GetBuild(ctx context.Context, id int64) (*Build, error)
- func (j *Job) GetBuildsFields(ctx context.Context, fields []string, custom interface{}) error
- func (j *Job) GetConfig(ctx context.Context) (string, error)
- func (j *Job) GetDescription() string
- func (j *Job) GetDetails() *JobResponse
- func (j *Job) GetDownstreamJobs(ctx context.Context) ([]*Job, error)
- func (j *Job) GetDownstreamJobsMetadata() []InnerJob
- func (j *Job) GetFirstBuild(ctx context.Context) (*Build, error)
- func (j *Job) GetInnerJob(ctx context.Context, id string) (*Job, error)
- func (j *Job) GetInnerJobs(ctx context.Context) ([]*Job, error)
- func (j *Job) GetInnerJobsMetadata() []InnerJob
- func (j *Job) GetLastBuild(ctx context.Context) (*Build, error)
- func (j *Job) GetLastCompletedBuild(ctx context.Context) (*Build, error)
- func (j *Job) GetLastFailedBuild(ctx context.Context) (*Build, error)
- func (j *Job) GetLastStableBuild(ctx context.Context) (*Build, error)
- func (j *Job) GetLastSuccessfulBuild(ctx context.Context) (*Build, error)
- func (j *Job) GetName() string
- func (j *Job) GetParameters(ctx context.Context) ([]ParameterDefinition, error)
- func (job *Job) GetPipelineRun(ctx context.Context, id string) (pr *PipelineRun, err error)
- func (job *Job) GetPipelineRuns(ctx context.Context) (pr []PipelineRun, err error)
- func (j *Job) GetUpstreamJobs(ctx context.Context) ([]*Job, error)
- func (j *Job) GetUpstreamJobsMetadata() []InnerJob
- func (j *Job) HasQueuedBuild(ctx context.Context) (bool, error)
- func (j *Job) History(ctx context.Context) ([]*History, error)
- func (j *Job) Invoke(ctx context.Context, files []string, skipIfRunning bool, ...) (bool, error)
- func (j *Job) InvokeSimple(ctx context.Context, params map[string]string) (int64, error)
- func (j *Job) IsEnabled(ctx context.Context) (bool, error)
- func (j *Job) IsQueued(ctx context.Context) (bool, error)
- func (j *Job) IsRunning(ctx context.Context) (bool, error)
- func (j *Job) Poll(ctx context.Context) (int, error)
- func (j *Job) Rename(ctx context.Context, name string) (bool, error)
- func (j *Job) UpdateConfig(ctx context.Context, config string) error
- type JobBuild
- type JobResponse
- type Label
- type LabelNode
- type LabelResponse
- type MODE
- type Node
- func (n *Node) Delete(ctx context.Context) (bool, error)
- func (n *Node) Disconnect(ctx context.Context) (int, error)
- func (n *Node) GetLogText(ctx context.Context) (string, error)
- func (n *Node) GetName() string
- func (n *Node) Info(ctx context.Context) (*NodeResponse, error)
- func (n *Node) IsIdle(ctx context.Context) (bool, error)
- func (n *Node) IsJnlpAgent(ctx context.Context) (bool, error)
- func (n *Node) IsOnline(ctx context.Context) (bool, error)
- func (n *Node) IsTemporarilyOffline(ctx context.Context) (bool, error)
- func (n *Node) LaunchNodeBySSH(ctx context.Context) (int, error)
- func (n *Node) Poll(ctx context.Context) (int, error)
- func (n *Node) SetOffline(ctx context.Context, options ...interface{}) (bool, error)
- func (n *Node) SetOnline(ctx context.Context) (bool, error)
- func (n *Node) ToggleTemporarilyOffline(ctx context.Context, options ...interface{}) (bool, error)
- type NodeResponse
- type ParameterDefinition
- type PipelineArtifact
- type PipelineInputAction
- type PipelineNode
- type PipelineNodeLog
- type PipelineRun
- func (pr *PipelineRun) AbortInput(ctx context.Context) (bool, error)
- func (pr *PipelineRun) GetArtifacts(ctx context.Context) (artifacts []PipelineArtifact, err error)
- func (pr *PipelineRun) GetNode(ctx context.Context, id string) (node *PipelineNode, err error)
- func (pr *PipelineRun) GetPendingInputActions(ctx context.Context) (PIAs []PipelineInputAction, err error)
- func (pr *PipelineRun) ProceedInput(ctx context.Context) (bool, error)
- type Plugin
- type PluginResponse
- type Plugins
- type PrivateKey
- type PrivateKeyFile
- type Queue
- type Requester
- func (r *Requester) Do(ctx context.Context, ar *APIRequest, responseStruct interface{}, ...) (*http.Response, error)
- func (r *Requester) Get(ctx context.Context, endpoint string, responseStruct interface{}, ...) (*http.Response, error)
- func (r *Requester) GetJSON(ctx context.Context, endpoint string, responseStruct interface{}, ...) (*http.Response, error)
- func (r *Requester) GetXML(ctx context.Context, endpoint string, responseStruct interface{}, ...) (*http.Response, error)
- func (r *Requester) Post(ctx context.Context, endpoint string, payload io.Reader, ...) (*http.Response, error)
- func (r *Requester) PostFiles(ctx context.Context, endpoint string, payload io.Reader, ...) (*http.Response, error)
- func (r *Requester) PostJSON(ctx context.Context, endpoint string, payload io.Reader, ...) (*http.Response, error)
- func (r *Requester) PostXML(ctx context.Context, endpoint string, xml string, responseStruct interface{}, ...) (*http.Response, error)
- func (r *Requester) ReadJSONResponse(response *http.Response, responseStruct interface{}) (*http.Response, error)
- func (r *Requester) ReadRawResponse(response *http.Response, responseStruct interface{}) (*http.Response, error)
- func (r *Requester) SetClient(client *http.Client) *Requester
- func (r *Requester) SetCrumb(ctx context.Context, ar *APIRequest) error
- type SSHCredentials
- type StringCredentials
- type Task
- type TestResult
- type User
- type UsernameCredentials
- type View
- func (v *View) AddJob(ctx context.Context, name string) (bool, error)
- func (v *View) DeleteJob(ctx context.Context, name string) (bool, error)
- func (v *View) GetDescription() string
- func (v *View) GetJobs() []InnerJob
- func (v *View) GetName() string
- func (v *View) GetUrl() string
- func (v *View) Poll(ctx context.Context) (int, error)
- type ViewData
- type ViewResponse
Constants ¶
const ( STATUS_FAIL = "FAIL" STATUS_ERROR = "ERROR" STATUS_ABORTED = "ABORTED" STATUS_REGRESSION = "REGRESSION" STATUS_SUCCESS = "SUCCESS" STATUS_FIXED = "FIXED" STATUS_PASSED = "PASSED" RESULT_STATUS_FAILURE = "FAILURE" RESULT_STATUS_FAILED = "FAILED" RESULT_STATUS_SKIPPED = "SKIPPED" STR_RE_SPLIT_VIEW = "(.*)/view/([^/]*)/?" )
const ClassUsernameCredentials = "com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl"
ClassUsernameCredentials is name if java class which implements credentials that store username-password pair
const KeySourceDirectEntryType = "com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey$DirectEntryPrivateKeySource"
KeySourceDirectEntryType is used when secret in provided directly as private key value
const KeySourceOnMasterType = "com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey$FileOnMasterPrivateKeySource"
KeySourceOnMasterType is used when private key value is path to file on jenkins master
Variables ¶
Loggers
var ( LIST_VIEW = "hudson.model.ListView" NESTED_VIEW = "hudson.plugins.nested_view.NestedView" MY_VIEW = "hudson.model.MyView" DASHBOARD_VIEW = "hudson.plugins.view.dashboard.Dashboard" PIPELINE_VIEW = "au.com.centrumsystems.hudson.plugin.buildpipeline.BuildPipelineView" )
View type constants for creating different types of views.
Functions ¶
This section is empty.
Types ¶
type APIRequest ¶ added in v1.0.1
type APIRequest struct {
Method string
Endpoint string
Payload io.Reader
Headers http.Header
Suffix string
}
APIRequest represents an HTTP request to the Jenkins API.
func NewAPIRequest ¶ added in v1.0.1
func NewAPIRequest(method string, endpoint string, payload io.Reader) *APIRequest
NewAPIRequest creates a new API request with the specified method, endpoint, and payload.
func (*APIRequest) SetHeader ¶ added in v1.0.1
func (ar *APIRequest) SetHeader(key string, value string) *APIRequest
SetHeader sets a header on the API request.
type APIToken ¶ added in v1.2.0
type APIToken struct {
Jenkins *Jenkins
Name string `json:"tokenName"`
UUID string `json:"tokenUuid"`
Value string `json:"tokenValue"`
}
APIToken is a Jenkins API token to be created for the user instantiated with the Jenkins client
type APITokenGenerateResponse ¶ added in v1.2.0
APITokenGenerateResponse is the response given by Jenkins when an API token is created
type Artifact ¶
Represents an Artifact
type Build ¶
type Build struct {
Raw *BuildResponse
Job *Job
Jenkins *Jenkins
Base string
Depth int
}
Build represents a Jenkins build and provides methods to interact with it.
func (*Build) GetActions ¶
func (b *Build) GetActions() []generalObj
GetActions returns all actions associated with the build.
func (*Build) GetAllFingerPrints ¶ added in v1.0.1
func (b *Build) GetAllFingerPrints(ctx context.Context) []*FingerPrint
GetAllFingerPrints returns all fingerprints associated with this build.
func (*Build) GetArtifacts ¶
GetArtifacts returns all artifacts produced by the build.
func (*Build) GetBuildNumber ¶
GetBuildNumber returns the build number.
func (*Build) GetConsoleOutput ¶
GetConsoleOutput returns the complete console output of the build.
func (*Build) GetConsoleOutputFromIndex ¶ added in v1.0.1
func (b *Build) GetConsoleOutputFromIndex(ctx context.Context, startID int64) (consoleResponse, error)
GetConsoleOutputFromIndex returns console output starting from a specific byte offset. Useful for streaming logs progressively.
func (*Build) GetCulprits ¶
GetCulprits returns the list of users who may have caused the build to fail.
func (*Build) GetDownstreamBuilds ¶
GetDownstreamBuilds returns all downstream builds triggered by this build.
func (*Build) GetDownstreamJobNames ¶
GetDownstreamJobNames returns the names of downstream jobs that used artifacts from this build.
func (*Build) GetDuration ¶
GetDuration returns the duration of the build in milliseconds.
func (*Build) GetInjectedEnvVars ¶ added in v1.0.1
GetInjectedEnvVars returns the environment variables injected into the build.
func (*Build) GetMatrixRuns ¶
GetMatrixRuns returns all matrix configuration builds for a matrix project build.
func (*Build) GetParameters ¶
func (b *Build) GetParameters() []parameter
GetParameters returns the parameters used to trigger the build.
func (*Build) GetResult ¶
GetResult returns the result status of the build (e.g., SUCCESS, FAILURE).
func (*Build) GetResultSet ¶
func (b *Build) GetResultSet(ctx context.Context) (*TestResult, error)
GetResultSet returns the test results for the build.
func (*Build) GetRevision ¶
GetRevision returns the VCS revision (commit hash) associated with the build.
func (*Build) GetRevisionBranch ¶ added in v1.0.1
GetRevisionBranch returns the git branch SHA1 for the build.
func (*Build) GetTimestamp ¶
GetTimestamp returns the time when the build started.
func (*Build) GetUpstreamBuild ¶
GetUpstreamBuild returns the upstream build that triggered this build.
func (*Build) GetUpstreamBuildNumber ¶
GetUpstreamBuildNumber returns the build number of the upstream build that triggered this build.
func (*Build) GetUpstreamJob ¶
GetUpstreamJob returns the job that triggered this build.
func (*Build) Info ¶
func (b *Build) Info() *BuildResponse
Info returns the raw BuildResponse containing all build details.
func (*Build) Poll ¶
Poll for current data. Optional parameter - depth. More about depth here: https://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API
func (*Build) SetDescription ¶ added in v1.0.1
SetDescription sets the description for the build.
type BuildResponse ¶ added in v1.0.1
type BuildResponse struct {
Actions []generalObj
Artifacts []struct {
DisplayPath string `json:"displayPath"`
FileName string `json:"fileName"`
RelativePath string `json:"relativePath"`
} `json:"artifacts"`
Building bool `json:"building"`
BuiltOn string `json:"builtOn"`
ChangeSet struct {
Items []struct {
AffectedPaths []string `json:"affectedPaths"`
Author struct {
AbsoluteUrl string `json:"absoluteUrl"`
FullName string `json:"fullName"`
} `json:"author"`
Comment string `json:"comment"`
CommitID string `json:"commitId"`
Date string `json:"date"`
ID string `json:"id"`
Msg string `json:"msg"`
Paths []struct {
EditType string `json:"editType"`
File string `json:"file"`
} `json:"paths"`
Timestamp int64 `json:"timestamp"`
} `json:"items"`
Kind string `json:"kind"`
Revisions []struct {
Module string
Revision int
} `json:"revision"`
} `json:"changeSet"`
ChangeSets []struct {
Items []struct {
AffectedPaths []string `json:"affectedPaths"`
Author struct {
AbsoluteUrl string `json:"absoluteUrl"`
FullName string `json:"fullName"`
} `json:"author"`
Comment string `json:"comment"`
CommitID string `json:"commitId"`
Date string `json:"date"`
ID string `json:"id"`
Msg string `json:"msg"`
Paths []struct {
EditType string `json:"editType"`
File string `json:"file"`
} `json:"paths"`
Timestamp int64 `json:"timestamp"`
} `json:"items"`
Kind string `json:"kind"`
Revisions []struct {
Module string
Revision int
} `json:"revision"`
} `json:"changeSets"`
Culprits []Culprit `json:"culprits"`
Description interface{} `json:"description"`
Duration float64 `json:"duration"`
EstimatedDuration float64 `json:"estimatedDuration"`
Executor interface{} `json:"executor"`
DisplayName string `json:"displayName"`
FullDisplayName string `json:"fullDisplayName"`
ID string `json:"id"`
KeepLog bool `json:"keepLog"`
Number int64 `json:"number"`
QueueID int64 `json:"queueId"`
Result string `json:"result"`
Timestamp int64 `json:"timestamp"`
URL string `json:"url"`
MavenArtifacts interface{} `json:"mavenArtifacts"`
MavenVersionUsed string `json:"mavenVersionUsed"`
FingerPrint []FingerPrintResponse
Runs []struct {
Number int64
URL string
} `json:"runs"`
}
BuildResponse represents the JSON response from the Jenkins API for a build.
type BuildRevision ¶
type BuildRevision struct {
SHA1 string `json:"SHA1"`
Branch []branch `json:"branch"`
}
BuildRevision represents a VCS revision associated with a build.
type Builds ¶
type Builds struct {
BuildNumber int64 `json:"buildNumber"`
BuildResult interface{} `json:"buildResult"`
Marked BuildRevision `json:"marked"`
Revision BuildRevision `json:"revision"`
}
Builds represents build information for branches in a multi-branch project.
type Computers ¶
type Computers struct {
BusyExecutors int `json:"busyExecutors"`
Computers []*NodeResponse `json:"computer"`
DisplayName string `json:"displayName"`
TotalExecutors int `json:"totalExecutors"`
}
Computers represents a collection of Jenkins nodes (agents).
type CredentialsManager ¶ added in v1.0.1
CredentialsManager is utility to control credential plugin Credentials declared by it can be used in jenkins jobs
func (CredentialsManager) Add ¶ added in v1.0.1
func (cm CredentialsManager) Add(ctx context.Context, domain string, creds interface{}) error
Add creates a new credential in the specified domain. The creds parameter must be a struct that can be marshaled to XML.
func (CredentialsManager) Delete ¶ added in v1.0.1
Delete removes a credential from the specified domain.
func (CredentialsManager) GetSingle ¶ added in v1.0.1
func (cm CredentialsManager) GetSingle(ctx context.Context, domain string, id string, creds interface{}) error
GetSingle retrieves a single credential by domain and ID. The credential is parsed as XML into the creds parameter (must be a pointer to struct).
func (CredentialsManager) List ¶ added in v1.0.1
List returns the IDs of all credentials stored in the specified domain.
func (CredentialsManager) Update ¶ added in v1.0.1
func (cm CredentialsManager) Update(ctx context.Context, domain string, id string, creds interface{}) error
Update modifies an existing credential in the specified domain. The creds parameter must be a pointer to struct that can be marshaled to XML.
type DockerServerCredentials ¶ added in v1.0.1
type DockerServerCredentials struct {
XMLName xml.Name `xml:"org.jenkinsci.plugins.docker.commons.credentials.DockerServerCredentials"`
ID string `xml:"id"`
Scope string `xml:"scope"`
Username string `xml:"username"`
Description string `xml:"description,omitempty"`
ClientKey string `xml:"clientKey"`
ClientCertificate string `xml:"clientCertificate"`
ServerCaCertificate string `xml:"serverCaCertificate"`
}
DockerServerCredentials represents credentials for Docker server keys.
type ErrAPIToken ¶ added in v1.2.0
type ErrAPIToken struct {
Message string
}
ErrAPIToken occurs when there is error creating or revoking API tokens
func (*ErrAPIToken) Error ¶ added in v1.2.0
func (e *ErrAPIToken) Error() string
type ErrUser ¶ added in v1.2.0
type ErrUser struct {
Message string
}
ErrUser occurs when there is error creating or revoking Jenkins users
type Executor ¶
type Executor struct {
Raw *ExecutorResponse
Jenkins *Jenkins
}
Executor represents the Jenkins master executor information.
type ExecutorResponse ¶ added in v1.0.1
type ExecutorResponse struct {
AssignedLabels []map[string]string `json:"assignedLabels"`
Description interface{} `json:"description"`
Jobs []InnerJob `json:"jobs"`
Mode string `json:"mode"`
NodeDescription string `json:"nodeDescription"`
NodeName string `json:"nodeName"`
NumExecutors int64 `json:"numExecutors"`
OverallLoad struct{} `json:"overallLoad"`
PrimaryView struct {
Name string `json:"name"`
URL string `json:"url"`
} `json:"primaryView"`
QuietingDown bool `json:"quietingDown"`
SlaveAgentPort int64 `json:"slaveAgentPort"`
UnlabeledLoad struct{} `json:"unlabeledLoad"`
UseCrumbs bool `json:"useCrumbs"`
UseSecurity bool `json:"useSecurity"`
Views []ViewData `json:"views"`
}
ExecutorResponse represents the JSON response from the Jenkins API for the master executor.
type FileCredentials ¶ added in v1.2.0
type FileCredentials struct {
XMLName xml.Name `xml:"org.jenkinsci.plugins.plaincredentials.impl.FileCredentialsImpl"`
ID string `xml:"id"`
Scope string `xml:"scope"`
Description string `xml:"description"`
Filename string `xml:"fileName"`
SecretBytes string `xml:"secretBytes"`
}
FileCredentials represents credentials that store a file. SecretBytes is a base64 encoded file content.
type FingerPrint ¶ added in v1.0.1
type FingerPrint struct {
Jenkins *Jenkins
Base string
Id string
Raw *FingerPrintResponse
}
FingerPrint represents a Jenkins fingerprint used to track file usage across builds.
func (FingerPrint) GetInfo ¶ added in v1.0.1
func (f FingerPrint) GetInfo(ctx context.Context) (*FingerPrintResponse, error)
GetInfo returns the fingerprint details.
func (FingerPrint) Poll ¶ added in v1.0.1
func (f FingerPrint) Poll(ctx context.Context) (int, error)
Poll fetches the latest fingerprint data from Jenkins.
func (FingerPrint) Valid ¶ added in v1.0.1
func (f FingerPrint) Valid(ctx context.Context) (bool, error)
Valid returns true if the fingerprint exists and matches the expected hash.
func (FingerPrint) ValidateForBuild ¶ added in v1.0.1
func (f FingerPrint) ValidateForBuild(ctx context.Context, filename string, build *Build) (bool, error)
ValidateForBuild validates the fingerprint against a specific build and filename.
type FingerPrintResponse ¶ added in v1.0.1
type FingerPrintResponse struct {
FileName string `json:"fileName"`
Hash string `json:"hash"`
Original struct {
Name string
Number int64
} `json:"original"`
Timestamp int64 `json:"timestamp"`
Usage []struct {
Name string `json:"name"`
Ranges struct {
Ranges []struct {
End int64 `json:"end"`
Start int64 `json:"start"`
} `json:"ranges"`
} `json:"ranges"`
} `json:"usage"`
}
FingerPrintResponse represents the JSON response from the Jenkins API for a fingerprint.
type Folder ¶ added in v1.0.1
type Folder struct {
Raw *FolderResponse
Jenkins *Jenkins
Base string
}
Folder represents a Jenkins folder that can contain jobs and other folders.
type FolderResponse ¶ added in v1.0.1
type FolderResponse struct {
Actions []generalObj
Description string `json:"description"`
DisplayName string `json:"displayName"`
Name string `json:"name"`
URL string `json:"url"`
Jobs []InnerJob `json:"jobs"`
PrimaryView *ViewData `json:"primaryView"`
Views []ViewData `json:"views"`
}
FolderResponse represents the JSON response from the Jenkins API for a folder.
type History ¶ added in v1.0.1
type History struct {
BuildDisplayName string
BuildNumber int
BuildStatus string
BuildTimestamp int64
}
History represents a build history entry with status and timestamp information.
type InnerJob ¶ added in v1.0.1
type InnerJob struct {
Class string `json:"_class"`
Name string `json:"name"`
Url string `json:"url"`
Color string `json:"color"`
}
InnerJob represents a nested job within a folder or multibranch pipeline.
type Jenkins ¶
type Jenkins struct {
Server string
Version string
Raw *ExecutorResponse
Requester JenkinsRequester
}
func CreateJenkins ¶
Creates a new Jenkins Instance Optional parameters are: client, username, password or token After creating an instance call init method.
func (*Jenkins) BuildJob ¶
func (j *Jenkins) BuildJob(ctx context.Context, name string, params map[string]string) (int64, error)
Invoke a job. First parameter job name, second parameter is optional Build parameters. Returns queue id
func (*Jenkins) CopyJob ¶
Create a copy of a job. First parameter Name of the job to copy from, Second parameter new job name.
func (*Jenkins) CreateFolder ¶ added in v1.0.1
func (j *Jenkins) CreateFolder(ctx context.Context, name string, parents ...string) (*Folder, error)
Create a new folder This folder can be nested in other parent folders Example: jenkins.CreateFolder("newFolder", "grandparentFolder", "parentFolder")
func (*Jenkins) CreateJob ¶
func (j *Jenkins) CreateJob(ctx context.Context, config string, options ...interface{}) (*Job, error)
Create a new job from config File Method takes XML string as first parameter, and if the name is not specified in the config file takes name as string as second parameter e.g jenkins.CreateJob("<config></config>","newJobName")
func (*Jenkins) CreateJobInFolder ¶ added in v1.0.1
func (j *Jenkins) CreateJobInFolder(ctx context.Context, config string, jobName string, parentIDs ...string) (*Job, error)
Create a new job in the folder Example: jenkins.CreateJobInFolder("<config></config>", "newJobName", "myFolder", "parentFolder")
func (*Jenkins) CreateNode ¶
func (j *Jenkins) CreateNode(ctx context.Context, name string, numExecutors int, description string, remoteFS string, label string, options ...interface{}) (*Node, error)
Create a new Node Can be JNLPLauncher or SSHLauncher Example : jenkins.CreateNode("nodeName", 1, "Description", "/var/lib/jenkins", "jdk8 docker", map[string]string{"method": "JNLPLauncher"}) By Default JNLPLauncher is created Multiple labels should be separated by blanks
func (*Jenkins) CreateUser ¶ added in v1.2.0
func (j *Jenkins) CreateUser(ctx context.Context, userName, password, fullName, email string) (User, error)
CreateUser creates a new Jenkins account
func (*Jenkins) CreateView ¶ added in v0.2.0
Create View First Parameter - name of the View Second parameter - Type Possible Types:
gojenkins.LIST_VIEW gojenkins.NESTED_VIEW gojenkins.MY_VIEW gojenkins.DASHBOARD_VIEW gojenkins.PIPELINE_VIEW
Example: jenkins.CreateView("newView",gojenkins.LIST_VIEW)
func (*Jenkins) DeleteNode ¶ added in v1.0.1
Delete a Jenkins slave node
func (*Jenkins) DeleteUser ¶ added in v1.2.0
DeleteUser deletes a Jenkins account
func (*Jenkins) GenerateAPIToken ¶ added in v1.2.0
GenerateAPIToken creates a new API token for the Jenkins client user
func (*Jenkins) GetAllBuildIds ¶ added in v0.2.0
Get all builds Numbers and URLS for a specific job. There are only build IDs here, To get all the other info of the build use jenkins.GetBuild(job,buildNumber) or job.GetBuild(buildNumber)
func (*Jenkins) GetAllJobNames ¶ added in v1.0.1
Get Only Array of Job Names, Color, URL Does not query each single Job.
func (*Jenkins) GetAllJobs ¶
Get All Possible Job Objects. Each job will be queried.
func (*Jenkins) GetAllNodes ¶
GetAllNodes retrieves all nodes (agents) in Jenkins.
func (*Jenkins) GetAllViews ¶ added in v0.2.0
GetAllViews retrieves all views in Jenkins.
func (*Jenkins) GetArtifactData ¶
Get Artifact data by Hash
func (*Jenkins) GetBuildFromQueueID ¶ added in v1.1.0
A task in queue will be assigned a build number in a job after a few seconds. this function will return the build object.
func (*Jenkins) GetFolder ¶ added in v1.0.1
GetFolder retrieves a folder by its ID. Parent folder IDs can be provided for nested folders.
func (*Jenkins) GetJob ¶
GetJob retrieves a job by its ID. Parent IDs can be provided for nested jobs.
func (*Jenkins) GetPlugins ¶
Returns the list of all plugins installed on the Jenkins server. You can supply depth parameter, to limit how much data is returned.
func (*Jenkins) GetQueueItem ¶ added in v1.0.1
GetQueueItem returns a single queue Task
func (*Jenkins) GetQueueUrl ¶
func (*Jenkins) GetSubJob ¶ added in v1.0.1
GetSubJob retrieves a nested job within a parent job or folder.
func (*Jenkins) HasPlugin ¶
Check if the plugin is installed on the server. Depth level 1 is used. If you need to go deeper, you can use GetPlugins, and iterate through them.
func (*Jenkins) Info ¶
func (j *Jenkins) Info(ctx context.Context) (*ExecutorResponse, error)
Get Basic Information About Jenkins
func (*Jenkins) Init ¶
Init Method. Should be called after creating a Jenkins Instance. e.g jenkins,err := CreateJenkins("url").Init() HTTP Client is set here, Connection to jenkins is tested here.
func (*Jenkins) InstallPlugin ¶ added in v1.0.1
InstallPlugin with given version and name
func (*Jenkins) RenameJob ¶
RenameJob renames a job. First parameter job old name, second parameter job new name.
func (*Jenkins) RevokeAPIToken ¶ added in v1.2.0
RevokeAPIToken revokes an API token
func (*Jenkins) RevokeAllAPITokens ¶ added in v1.2.0
RevokeAllAPITokens revokes all API tokens for the Jenkins client user
func (*Jenkins) SafeRestart ¶ added in v1.0.1
SafeRestart jenkins, restart will be done when there are no jobs running
func (*Jenkins) UninstallPlugin ¶ added in v1.0.1
UninstallPlugin plugin otherwise returns error
type JenkinsRequester ¶ added in v1.2.0
type JenkinsRequester interface {
GetJSON(ctx context.Context, endpoint string, response interface{}, query map[string]string) (*http.Response, error)
Post(ctx context.Context, endpoint string, payload io.Reader, response interface{}, query map[string]string) (*http.Response, error)
PostXML(ctx context.Context, endpoint string, xml string, response interface{}, query map[string]string) (*http.Response, error)
PostJSON(ctx context.Context, endpoint string, payload io.Reader, response interface{}, query map[string]string) (*http.Response, error)
PostFiles(ctx context.Context, endpoint string, payload io.Reader, response interface{}, query map[string]string, files []string) (*http.Response, error)
Get(ctx context.Context, endpoint string, response interface{}, query map[string]string) (*http.Response, error)
GetXML(ctx context.Context, endpoint string, response interface{}, query map[string]string) (*http.Response, error)
}
JenkinsRequester defines the interface for making Jenkins API requests. This interface enables mocking for unit tests.
type Job ¶
type Job struct {
Raw *JobResponse
Jenkins *Jenkins
Base string
}
Job represents a Jenkins job and provides methods to interact with it.
func (*Job) Create ¶
Create creates a new job with the given XML configuration. Optional query parameters can be passed as the third argument.
func (*Job) GetAllBuildIds ¶ added in v0.2.0
Returns All Builds with Number and URL
func (*Job) GetBuildsFields ¶ added in v1.1.0
GetBuildsFields retrieves specific fields from the last 100 builds into a custom struct. The fields parameter specifies which build properties to fetch.
func (*Job) GetDescription ¶
GetDescription returns the description of the job.
func (*Job) GetDetails ¶
func (j *Job) GetDetails() *JobResponse
GetDetails returns the raw JobResponse containing all job details.
func (*Job) GetDownstreamJobs ¶
GetDownstreamJobs retrieves all downstream jobs with full details.
func (*Job) GetDownstreamJobsMetadata ¶
GetDownstreamJobsMetadata returns metadata for all downstream jobs without fetching full details.
func (*Job) GetFirstBuild ¶
GetFirstBuild returns the first build of the job.
func (*Job) GetInnerJob ¶ added in v1.0.1
GetInnerJob retrieves a specific inner job by its name.
func (*Job) GetInnerJobs ¶ added in v1.0.1
GetInnerJobs retrieves all inner jobs with full details.
func (*Job) GetInnerJobsMetadata ¶ added in v1.0.1
GetInnerJobsMetadata returns metadata for all inner jobs (e.g., in a folder) without fetching full details.
func (*Job) GetLastBuild ¶
GetLastBuild returns the most recent build of the job.
func (*Job) GetLastCompletedBuild ¶
GetLastCompletedBuild returns the last completed build of the job (successful or failed).
func (*Job) GetLastFailedBuild ¶
GetLastFailedBuild returns the last failed build of the job.
func (*Job) GetLastStableBuild ¶
GetLastStableBuild returns the last stable build of the job.
func (*Job) GetLastSuccessfulBuild ¶
GetLastSuccessfulBuild returns the last successful build of the job.
func (*Job) GetParameters ¶
func (j *Job) GetParameters(ctx context.Context) ([]ParameterDefinition, error)
GetParameters returns the parameter definitions for a parameterized job.
func (*Job) GetPipelineRun ¶ added in v1.0.1
GetPipelineRun returns a specific pipeline run by its ID.
func (*Job) GetPipelineRuns ¶ added in v1.0.1
func (job *Job) GetPipelineRuns(ctx context.Context) (pr []PipelineRun, err error)
GetPipelineRuns returns all pipeline runs for a pipeline job.
func (*Job) GetUpstreamJobs ¶
GetUpstreamJobs retrieves all upstream jobs with full details.
func (*Job) GetUpstreamJobsMetadata ¶
GetUpstreamJobsMetadata returns metadata for all upstream jobs without fetching full details.
func (*Job) HasQueuedBuild ¶
HasQueuedBuild returns true if the job has a build waiting in the queue.
func (*Job) Invoke ¶
func (j *Job) Invoke(ctx context.Context, files []string, skipIfRunning bool, params map[string]string, cause string, securityToken string) (bool, error)
Invoke triggers a build with optional file parameters, build parameters, and security token. If skipIfRunning is true, the build will not be triggered if the job is already running.
func (*Job) InvokeSimple ¶
InvokeSimple triggers a build with the given parameters and returns the queue item number. It automatically chooses between /build and /buildWithParameters based on job configuration.
func (*Job) Poll ¶
Poll fetches the latest job data from Jenkins and updates the Raw field. Returns the HTTP status code of the response.
type JobBuild ¶ added in v1.0.1
JobBuild represents basic build information including its number and URL.
type JobResponse ¶ added in v1.0.1
type JobResponse struct {
Class string `json:"_class"`
Actions []generalObj
Buildable bool `json:"buildable"`
Builds []JobBuild
Color string `json:"color"`
ConcurrentBuild bool `json:"concurrentBuild"`
Description string `json:"description"`
DisplayName string `json:"displayName"`
DisplayNameOrNull interface{} `json:"displayNameOrNull"`
DownstreamProjects []InnerJob `json:"downstreamProjects"`
FirstBuild JobBuild
FullName string `json:"fullName"`
FullDisplayName string `json:"fullDisplayName"`
HealthReport []struct {
Description string `json:"description"`
IconClassName string `json:"iconClassName"`
IconUrl string `json:"iconUrl"`
Score int64 `json:"score"`
} `json:"healthReport"`
InQueue bool `json:"inQueue"`
KeepDependencies bool `json:"keepDependencies"`
LastBuild JobBuild `json:"lastBuild"`
LastCompletedBuild JobBuild `json:"lastCompletedBuild"`
LastFailedBuild JobBuild `json:"lastFailedBuild"`
LastStableBuild JobBuild `json:"lastStableBuild"`
LastSuccessfulBuild JobBuild `json:"lastSuccessfulBuild"`
LastUnstableBuild JobBuild `json:"lastUnstableBuild"`
LastUnsuccessfulBuild JobBuild `json:"lastUnsuccessfulBuild"`
Name string `json:"name"`
NextBuildNumber int64 `json:"nextBuildNumber"`
Property []struct {
ParameterDefinitions []ParameterDefinition `json:"parameterDefinitions"`
} `json:"property"`
QueueItem interface{} `json:"queueItem"`
Scm struct{} `json:"scm"`
UpstreamProjects []InnerJob `json:"upstreamProjects"`
URL string `json:"url"`
Jobs []InnerJob `json:"jobs"`
PrimaryView *ViewData `json:"primaryView"`
Views []ViewData `json:"views"`
}
JobResponse represents the JSON response from the Jenkins API for a job.
type Label ¶ added in v1.0.1
type Label struct {
Raw *LabelResponse
Jenkins *Jenkins
Base string
}
Label represents a Jenkins label used to group nodes.
type LabelNode ¶ added in v1.0.1
type LabelNode struct {
NodeName string `json:"nodeName"`
NodeDescription string `json:"nodeDescription"`
NumExecutors int64 `json:"numExecutors"`
Mode string `json:"mode"`
Class string `json:"_class"`
}
LabelNode represents a node associated with a label.
type LabelResponse ¶ added in v1.0.1
type LabelResponse struct {
Name string `json:"name"`
Description string `json:"description"`
Nodes []LabelNode `json:"nodes"`
Offline bool `json:"offline"`
IdleExecutors int64 `json:"idleExecutors"`
BusyExecutors int64 `json:"busyExecutors"`
TotalExecutors int64 `json:"totalExecutors"`
}
LabelResponse represents the JSON response from the Jenkins API for a label.
type Node ¶
type Node struct {
Raw *NodeResponse
Jenkins *Jenkins
Base string
}
Node represents a Jenkins agent (slave) node.
func (*Node) Disconnect ¶ added in v1.0.1
Disconnect disconnects the node from Jenkins.
func (*Node) GetLogText ¶ added in v1.0.1
GetLogText returns the agent log text for the node.
func (*Node) Info ¶
func (n *Node) Info(ctx context.Context) (*NodeResponse, error)
Info returns the node details after polling for the latest data.
func (*Node) IsJnlpAgent ¶
IsJnlpAgent returns true if the node is a JNLP (Java Web Start) agent.
func (*Node) IsTemporarilyOffline ¶
IsTemporarilyOffline returns true if the node is temporarily marked offline.
func (*Node) LaunchNodeBySSH ¶ added in v1.0.1
LaunchNodeBySSH launches the node's agent via SSH.
func (*Node) SetOffline ¶
SetOffline marks the node as temporarily offline with an optional message.
type NodeResponse ¶ added in v1.0.1
type NodeResponse struct {
Class string `json:"_class"`
Actions []interface{} `json:"actions"`
DisplayName string `json:"displayName"`
Executors []struct {
CurrentExecutable struct {
Number int `json:"number"`
URL string `json:"url"`
SubBuilds []struct {
Abort bool `json:"abort"`
Build interface{} `json:"build"`
BuildNumber int `json:"buildNumber"`
Duration string `json:"duration"`
Icon string `json:"icon"`
JobName string `json:"jobName"`
ParentBuildNumber int `json:"parentBuildNumber"`
ParentJobName string `json:"parentJobName"`
PhaseName string `json:"phaseName"`
Result string `json:"result"`
Retry bool `json:"retry"`
URL string `json:"url"`
} `json:"subBuilds"`
} `json:"currentExecutable"`
} `json:"executors"`
Icon string `json:"icon"`
IconClassName string `json:"iconClassName"`
Idle bool `json:"idle"`
JnlpAgent bool `json:"jnlpAgent"`
LaunchSupported bool `json:"launchSupported"`
LoadStatistics struct{} `json:"loadStatistics"`
ManualLaunchAllowed bool `json:"manualLaunchAllowed"`
MonitorData struct {
Hudson_NodeMonitors_ArchitectureMonitor interface{} `json:"hudson.node_monitors.ArchitectureMonitor"`
Hudson_NodeMonitors_ClockMonitor interface{} `json:"hudson.node_monitors.ClockMonitor"`
Hudson_NodeMonitors_DiskSpaceMonitor interface{} `json:"hudson.node_monitors.DiskSpaceMonitor"`
Hudson_NodeMonitors_ResponseTimeMonitor struct {
Average int64 `json:"average"`
} `json:"hudson.node_monitors.ResponseTimeMonitor"`
Hudson_NodeMonitors_SwapSpaceMonitor interface{} `json:"hudson.node_monitors.SwapSpaceMonitor"`
Hudson_NodeMonitors_TemporarySpaceMonitor interface{} `json:"hudson.node_monitors.TemporarySpaceMonitor"`
} `json:"monitorData"`
NumExecutors int64 `json:"numExecutors"`
Offline bool `json:"offline"`
OfflineCause struct{} `json:"offlineCause"`
OfflineCauseReason string `json:"offlineCauseReason"`
OneOffExecutors []interface{} `json:"oneOffExecutors"`
TemporarilyOffline bool `json:"temporarilyOffline"`
}
NodeResponse represents the JSON response from the Jenkins API for a node.
type ParameterDefinition ¶ added in v1.0.1
type ParameterDefinition struct {
DefaultParameterValue struct {
Name string `json:"name"`
Value interface{} `json:"value"`
} `json:"defaultParameterValue"`
Description string `json:"description"`
Name string `json:"name"`
Type string `json:"type"`
}
ParameterDefinition represents a build parameter definition for a parameterized job.
type PipelineArtifact ¶ added in v1.0.1
type PipelineArtifact struct {
ID string
Name string
Path string
URL string
Size int `json:"size"`
}
PipelineArtifact represents an artifact produced by a pipeline run.
type PipelineInputAction ¶ added in v1.0.1
PipelineInputAction represents a pending input action that requires user interaction.
type PipelineNode ¶ added in v1.0.1
type PipelineNode struct {
Run *PipelineRun
Base string
URLs map[string]map[string]string `json:"_links"`
ID string
Name string
Status string
StartTime int64 `json:"startTimeMillis"`
Duration int64 `json:"durationMillis"`
StageFlowNodes []PipelineNode
ParentNodes []int64
}
PipelineNode represents a stage or step within a pipeline run.
func (*PipelineNode) GetLog ¶ added in v1.0.1
func (node *PipelineNode) GetLog(ctx context.Context) (log *PipelineNodeLog, err error)
GetLog returns the console log output for a pipeline node.
type PipelineNodeLog ¶ added in v1.0.1
type PipelineNodeLog struct {
NodeID string
NodeStatus string
Length int64
HasMore bool
Text string
ConsoleURL string
}
PipelineNodeLog represents the console log output for a pipeline node.
type PipelineRun ¶ added in v1.0.1
type PipelineRun struct {
Job *Job
Base string
URLs map[string]map[string]string `json:"_links"`
ID string
Name string
Status string
StartTime int64 `json:"startTimeMillis"`
EndTime int64 `json:"endTimeMillis"`
Duration int64 `json:"durationMillis"`
Stages []PipelineNode
}
PipelineRun represents a single run of a Jenkins pipeline job.
func (*PipelineRun) AbortInput ¶ added in v1.0.1
func (pr *PipelineRun) AbortInput(ctx context.Context) (bool, error)
AbortInput aborts the first pending input action for a pipeline run.
func (*PipelineRun) GetArtifacts ¶ added in v1.0.1
func (pr *PipelineRun) GetArtifacts(ctx context.Context) (artifacts []PipelineArtifact, err error)
GetArtifacts returns all artifacts produced by a pipeline run.
func (*PipelineRun) GetNode ¶ added in v1.0.1
func (pr *PipelineRun) GetNode(ctx context.Context, id string) (node *PipelineNode, err error)
GetNode returns a specific pipeline node by its ID.
func (*PipelineRun) GetPendingInputActions ¶ added in v1.0.1
func (pr *PipelineRun) GetPendingInputActions(ctx context.Context) (PIAs []PipelineInputAction, err error)
GetPendingInputActions returns all pending input actions for a pipeline run.
func (*PipelineRun) ProceedInput ¶ added in v1.0.1
func (pr *PipelineRun) ProceedInput(ctx context.Context) (bool, error)
ProceedInput submits the first pending input action for a pipeline run.
type Plugin ¶
type Plugin struct {
Active bool `json:"active"`
BackupVersion interface{} `json:"backupVersion"`
Bundled bool `json:"bundled"`
Deleted bool `json:"deleted"`
Dependencies []struct {
Optional string `json:"optional"`
ShortName string `json:"shortname"`
Version string `json:"version"`
} `json:"dependencies"`
Downgradable bool `json:"downgradable"`
Enabled bool `json:"enabled"`
HasUpdate bool `json:"hasUpdate"`
LongName string `json:"longName"`
Pinned bool `json:"pinned"`
ShortName string `json:"shortName"`
SupportsDynamicLoad string `json:"supportsDynamicLoad"`
URL string `json:"url"`
Version string `json:"version"`
}
Plugin represents a single Jenkins plugin.
type PluginResponse ¶ added in v1.0.1
type PluginResponse struct {
Plugins []Plugin `json:"plugins"`
}
PluginResponse represents the JSON response from the Jenkins API for plugins.
type Plugins ¶
type Plugins struct {
Jenkins *Jenkins
Raw *PluginResponse
Base string
Depth int
}
Plugins represents the collection of installed Jenkins plugins.
func (*Plugins) Contains ¶
Contains checks if a plugin with the given name is installed. Returns the Plugin if found, nil otherwise.
type PrivateKey ¶ added in v1.0.1
PrivateKey is used in SSHCredentials type. Class can be either KeySourceDirectEntryType (value is the secret text) or KeySourceOnMasterType (value is the path on master where secret is stored).
type PrivateKeyFile ¶ added in v1.0.1
PrivateKeyFile represents a private key stored in a file on the Jenkins master.
type Queue ¶
Queue represents the Jenkins build queue.
func (*Queue) CancelTask ¶
CancelTask cancels a queued task by its ID.
func (*Queue) GetTaskById ¶
GetTaskById returns a task from the queue by its ID.
func (*Queue) GetTasksForJob ¶
GetTasksForJob returns all queued tasks for a specific job.
type Requester ¶
type Requester struct {
Base string
BasicAuth *BasicAuth
Client *http.Client
CACert []byte
SslVerify bool
}
Requester handles HTTP requests to the Jenkins API.
func (*Requester) Do ¶
func (r *Requester) Do(ctx context.Context, ar *APIRequest, responseStruct interface{}, options ...interface{}) (*http.Response, error)
Do executes the API request and returns the HTTP response.
func (*Requester) Get ¶
func (r *Requester) Get(ctx context.Context, endpoint string, responseStruct interface{}, querystring map[string]string) (*http.Response, error)
Get sends a GET request to the specified endpoint.
func (*Requester) GetJSON ¶
func (r *Requester) GetJSON(ctx context.Context, endpoint string, responseStruct interface{}, query map[string]string) (*http.Response, error)
GetJSON sends a GET request and expects a JSON response.
func (*Requester) GetXML ¶
func (r *Requester) GetXML(ctx context.Context, endpoint string, responseStruct interface{}, query map[string]string) (*http.Response, error)
GetXML sends a GET request and expects an XML response.
func (*Requester) Post ¶
func (r *Requester) Post(ctx context.Context, endpoint string, payload io.Reader, responseStruct interface{}, querystring map[string]string) (*http.Response, error)
Post sends a POST request with form-urlencoded content type.
func (*Requester) PostFiles ¶
func (r *Requester) PostFiles(ctx context.Context, endpoint string, payload io.Reader, responseStruct interface{}, querystring map[string]string, files []string) (*http.Response, error)
PostFiles sends a POST request with file attachments.
func (*Requester) PostJSON ¶ added in v1.0.1
func (r *Requester) PostJSON(ctx context.Context, endpoint string, payload io.Reader, responseStruct interface{}, querystring map[string]string) (*http.Response, error)
PostJSON sends a POST request with JSON content type.
func (*Requester) PostXML ¶
func (r *Requester) PostXML(ctx context.Context, endpoint string, xml string, responseStruct interface{}, querystring map[string]string) (*http.Response, error)
PostXML sends a POST request with XML content.
func (*Requester) ReadJSONResponse ¶ added in v1.0.1
func (r *Requester) ReadJSONResponse(response *http.Response, responseStruct interface{}) (*http.Response, error)
ReadJSONResponse reads the response body as JSON and decodes it into responseStruct.
func (*Requester) ReadRawResponse ¶ added in v1.0.1
func (r *Requester) ReadRawResponse(response *http.Response, responseStruct interface{}) (*http.Response, error)
ReadRawResponse reads the response body as a raw string.
type SSHCredentials ¶ added in v1.0.1
type SSHCredentials struct {
XMLName xml.Name `xml:"com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey"`
ID string `xml:"id"`
Scope string `xml:"scope"`
Username string `xml:"username"`
Description string `xml:"description,omitempty"`
PrivateKeySource interface{} `xml:"privateKeySource"`
Passphrase string `xml:"passphrase,omitempty"`
}
SSHCredentials represents credentials for SSH keys.
type StringCredentials ¶ added in v1.0.1
type StringCredentials struct {
XMLName xml.Name `xml:"org.jenkinsci.plugins.plaincredentials.impl.StringCredentialsImpl"`
ID string `xml:"id"`
Scope string `xml:"scope"`
Description string `xml:"description"`
Secret string `xml:"secret"`
}
StringCredentials represents credentials that store only a secret text value.
type Task ¶
Task represents a single item in the Jenkins build queue.
func (*Task) GetParameters ¶
func (t *Task) GetParameters() []parameter
GetParameters returns the build parameters for this task.
type TestResult ¶
type TestResult struct {
Duration float64 `json:"duration"`
Empty bool `json:"empty"`
FailCount int64 `json:"failCount"`
PassCount int64 `json:"passCount"`
SkipCount int64 `json:"skipCount"`
Suites []struct {
Cases []struct {
Age int64 `json:"age"`
ClassName string `json:"className"`
Duration float64 `json:"duration"`
ErrorDetails interface{} `json:"errorDetails"`
ErrorStackTrace interface{} `json:"errorStackTrace"`
FailedSince int64 `json:"failedSince"`
Name string `json:"name"`
Skipped bool `json:"skipped"`
SkippedMessage interface{} `json:"skippedMessage"`
Status string `json:"status"`
Stderr interface{} `json:"stderr"`
Stdout interface{} `json:"stdout"`
} `json:"cases"`
Duration float64 `json:"duration"`
ID interface{} `json:"id"`
Name string `json:"name"`
Stderr interface{} `json:"stderr"`
Stdout interface{} `json:"stdout"`
Timestamp interface{} `json:"timestamp"`
} `json:"suites"`
}
TestResult represents the test results of a build.
type UsernameCredentials ¶ added in v1.0.1
type UsernameCredentials struct {
XMLName xml.Name `xml:"com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl"`
ID string `xml:"id"`
Scope string `xml:"scope"`
Description string `xml:"description"`
Username string `xml:"username"`
Password string `xml:"password"`
}
UsernameCredentials struct representing credential for storing username-password pair
type View ¶ added in v0.2.0
type View struct {
Raw *ViewResponse
Jenkins *Jenkins
Base string
}
View represents a Jenkins view that organizes jobs.
func (*View) GetDescription ¶ added in v1.0.1
GetDescription returns the description of the view.
type ViewResponse ¶ added in v1.0.1
type ViewResponse struct {
Description string `json:"description"`
Jobs []InnerJob `json:"jobs"`
Name string `json:"name"`
Property []interface{} `json:"property"`
URL string `json:"url"`
}
ViewResponse represents the JSON response from the Jenkins API for a view.