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 Artifact
- type BasicAuth
- type Build
- func (b *Build) GetActions() []generalObj
- func (b *Build) GetAllFingerprints() []*Fingerprint
- func (b *Build) GetArtifacts() []Artifact
- func (b *Build) GetBuildNumber() int64
- func (b *Build) GetCauses() ([]map[string]interface{}, error)
- func (b *Build) GetConsoleOutput() string
- func (b *Build) GetCulprits() []culprit
- func (b *Build) GetDownstreamBuilds() ([]*Build, error)
- func (b *Build) GetDownstreamJobNames() []string
- func (b *Build) GetDuration() int64
- func (b *Build) GetInjectedEnvVars() (map[string]string, error)
- func (b *Build) GetMatrixRuns() ([]*Build, error)
- func (b *Build) GetParameters() []parameter
- func (b *Build) GetResult() string
- func (b *Build) GetResultSet() (*testResult, error)
- func (b *Build) GetRevision() string
- func (b *Build) GetRevisionBranch() string
- func (b *Build) GetTimestamp() time.Time
- func (b *Build) GetUpstreamBuild() (*Build, error)
- func (b *Build) GetUpstreamBuildNumber() (int64, error)
- func (b *Build) GetUpstreamJob() (*Job, error)
- func (b *Build) GetUrl() string
- func (b *Build) Info() *buildResponse
- func (b *Build) IsGood() bool
- func (b *Build) IsRunning() bool
- func (b *Build) Poll(options ...interface{}) (int, error)
- func (b *Build) SetDescription(description string) error
- func (b *Build) Stop() (bool, error)
- type Computers
- type Executor
- type Fingerprint
- type Jenkins
- func (j *Jenkins) BuildJob(name string, options ...interface{}) (int64, error)
- func (j *Jenkins) CopyJob(copyFrom string, newName string) (*Job, error)
- func (j *Jenkins) CreateJob(config string, options ...interface{}) (*Job, error)
- func (j *Jenkins) CreateNode(name string, numExecutors int, description string, remoteFS string, ...) (*Node, error)
- func (j *Jenkins) CreateView(name string, viewType string) (*View, error)
- func (j *Jenkins) DeleteJob(name string) (bool, error)
- func (j *Jenkins) GetAllBuildIds(job string) ([]jobBuild, error)
- func (j *Jenkins) GetAllJobNames() ([]job, error)
- func (j *Jenkins) GetAllJobs() ([]*Job, error)
- func (j *Jenkins) GetAllNodes() ([]*Node, error)
- func (j *Jenkins) GetAllViews() ([]*View, error)
- func (j *Jenkins) GetArtifactData(id string) (*fingerPrintResponse, error)
- func (j *Jenkins) GetBuild(jobName string, number int64) (*Build, error)
- func (j *Jenkins) GetJob(id string, parentIDs ...string) (*Job, error)
- func (j *Jenkins) GetLabel(name string) (*Label, error)
- func (j *Jenkins) GetNode(name string) (*Node, error)
- func (j *Jenkins) GetPlugins(depth int) (*Plugins, error)
- func (j *Jenkins) GetQueue() (*Queue, error)
- func (j *Jenkins) GetQueueUrl() string
- func (j *Jenkins) GetView(name string) (*View, error)
- func (j *Jenkins) HasPlugin(name string) (*Plugin, error)
- func (j *Jenkins) Info() (*executorResponse, error)
- func (j *Jenkins) Init() (*Jenkins, error)
- func (j *Jenkins) Poll() (int, error)
- func (j *Jenkins) RenameJob(job string, name string) *Job
- func (j *Jenkins) ValidateFingerPrint(id string) (bool, error)
- type Job
- func (j *Job) Copy(destinationName string) (*Job, error)
- func (j *Job) Create(config string, qr ...interface{}) (*Job, error)
- func (j *Job) Delete() (bool, error)
- func (j *Job) Disable() (bool, error)
- func (j *Job) Enable() (bool, error)
- func (j *Job) GetAllBuildIds() ([]jobBuild, error)
- func (j *Job) GetBuild(id int64) (*Build, error)
- func (j *Job) GetConfig() (string, error)
- func (j *Job) GetDescription() string
- func (j *Job) GetDetails() *jobResponse
- func (j *Job) GetDownstreamJobs() ([]*Job, error)
- func (j *Job) GetDownstreamJobsMetadata() []job
- func (j *Job) GetFirstBuild() (*Build, error)
- func (j *Job) GetInnerJob(id string) (*Job, error)
- func (j *Job) GetInnerJobs() ([]*Job, error)
- func (j *Job) GetInnerJobsMetadata() []job
- func (j *Job) GetLastBuild() (*Build, error)
- func (j *Job) GetLastCompletedBuild() (*Build, error)
- func (j *Job) GetLastFailedBuild() (*Build, error)
- func (j *Job) GetLastStableBuild() (*Build, error)
- func (j *Job) GetLastSuccessfulBuild() (*Build, error)
- func (j *Job) GetName() string
- func (j *Job) GetParameters() ([]parameterDefinition, error)
- func (j *Job) GetUpstreamJobs() ([]*Job, error)
- func (j *Job) GetUpstreamJobsMetadata() []job
- func (j *Job) HasQueuedBuild()
- func (j *Job) History() ([]*history, error)
- func (j *Job) Invoke(files []string, skipIfRunning bool, params map[string]string, cause string, ...) (bool, error)
- func (j *Job) InvokeSimple(params map[string]string) (int64, error)
- func (j *Job) IsEnabled() (bool, error)
- func (j *Job) IsQueued() (bool, error)
- func (j *Job) IsRunning() (bool, error)
- func (j *Job) Poll() (int, error)
- func (j *Job) Rename(name string) (bool, error)
- func (j *Job) UpdateConfig(config string) error
- type Label
- type LabelNode
- type LabelResponse
- type MODE
- type Node
- func (n *Node) Delete() (bool, error)
- func (n *Node) Disconnect() (int, error)
- func (n *Node) GetLogText() (string, error)
- func (n *Node) GetName() string
- func (n *Node) Info() (*NodeResponse, error)
- func (n *Node) IsIdle() (bool, error)
- func (n *Node) IsJnlpAgent() (bool, error)
- func (n *Node) IsOnline() (bool, error)
- func (n *Node) IsTemporarilyOffline() (bool, error)
- func (n *Node) LaunchNodeBySSH() (int, error)
- func (n *Node) Poll() (int, error)
- func (n *Node) SetOffline() (bool, error)
- func (n *Node) SetOnline() (bool, error)
- func (n *Node) ToggleTemporarilyOffline(options ...interface{}) (bool, error)
- type NodeResponse
- type Plugin
- type Plugins
- type Queue
- type Requester
- func (r *Requester) Do(ar *APIRequest, responseStruct interface{}, options ...interface{}) (*http.Response, error)
- func (r *Requester) Get(endpoint string, responseStruct interface{}, querystring map[string]string) (*http.Response, error)
- func (r *Requester) GetJSON(endpoint string, responseStruct interface{}, querystring map[string]string) (*http.Response, error)
- func (r *Requester) GetXML(endpoint string, responseStruct interface{}, querystring map[string]string) (*http.Response, error)
- func (r *Requester) Post(endpoint string, payload io.Reader, responseStruct interface{}, ...) (*http.Response, error)
- func (r *Requester) PostFiles(endpoint string, payload io.Reader, responseStruct interface{}, ...) (*http.Response, error)
- func (r *Requester) PostJSON(endpoint string, payload io.Reader, responseStruct interface{}, ...) (*http.Response, error)
- func (r *Requester) PostXML(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(ar *APIRequest) error
- type Task
- type View
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/([^/]*)/?" )
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" )
Functions ¶
This section is empty.
Types ¶
type APIRequest ¶
type APIRequest struct { Method string Endpoint string Payload io.Reader Headers http.Header Suffix string }
func NewAPIRequest ¶
func NewAPIRequest(method string, endpoint string, payload io.Reader) *APIRequest
func (*APIRequest) SetHeader ¶
func (ar *APIRequest) SetHeader(key string, value string) *APIRequest
type Artifact ¶
Represents an Artifact
type Build ¶
func (*Build) GetActions ¶
func (b *Build) GetActions() []generalObj
func (*Build) GetAllFingerprints ¶
func (b *Build) GetAllFingerprints() []*Fingerprint
func (*Build) GetArtifacts ¶
func (*Build) GetBuildNumber ¶
func (*Build) GetConsoleOutput ¶
func (*Build) GetCulprits ¶
func (b *Build) GetCulprits() []culprit
func (*Build) GetDownstreamBuilds ¶
func (*Build) GetDownstreamJobNames ¶
func (*Build) GetDuration ¶
func (*Build) GetMatrixRuns ¶
func (*Build) GetParameters ¶
func (b *Build) GetParameters() []parameter
func (*Build) GetResultSet ¶
func (*Build) GetRevision ¶
func (*Build) GetRevisionBranch ¶
func (*Build) GetTimestamp ¶
func (*Build) GetUpstreamBuild ¶
func (*Build) GetUpstreamBuildNumber ¶
func (*Build) GetUpstreamJob ¶
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 ¶
type Computers ¶
type Computers struct { BusyExecutors int `json:"busyExecutors"` Computers []*NodeResponse `json:"computer"` DisplayName string `json:"displayName"` TotalExecutors int `json:"totalExecutors"` }
type Fingerprint ¶
func (Fingerprint) GetInfo ¶
func (f Fingerprint) GetInfo() (*fingerPrintResponse, error)
func (Fingerprint) Poll ¶
func (f Fingerprint) Poll() (int, error)
func (Fingerprint) Valid ¶
func (f Fingerprint) Valid() (bool, error)
func (Fingerprint) ValidateForBuild ¶
func (f Fingerprint) ValidateForBuild(filename string, build *Build) (bool, error)
type Jenkins ¶
func CreateJenkins ¶
Creates a new Jenkins Instance Optional parameters are: username, password After creating an instance call init method.
func (*Jenkins) BuildJob ¶
Invoke a job. First parameter job name, second parameter is optional Build parameters.
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) CreateJob ¶
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) CreateNode ¶
func (j *Jenkins) CreateNode(name string, numExecutors int, description string, remoteFS string, options ...interface{}) (*Node, error)
Create a new Node Can be JNLPLauncher or SSHLauncher Example : jenkins.CreateNode("nodeName", 1, "Description", "/var/lib/jenkins", map[string]string{"method": "JNLPLauncher"}) By Default JNLPLauncher is created
func (*Jenkins) CreateView ¶
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) GetAllBuildIds ¶
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 ¶
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 ¶
func (*Jenkins) GetAllViews ¶
func (*Jenkins) GetArtifactData ¶
Get Artifact data by Hash
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) GetQueueUrl ¶
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) Init ¶
Init Method. Should be called after creating a Jenkins Instance. e.g jenkins := CreateJenkins("url").Init() HTTP Client is set here, Connection to jenkins is tested here.
type Job ¶
func (*Job) GetAllBuildIds ¶
Returns All Builds with Number and URL
func (*Job) GetDescription ¶
func (*Job) GetDetails ¶
func (j *Job) GetDetails() *jobResponse
func (*Job) GetDownstreamJobs ¶
func (*Job) GetDownstreamJobsMetadata ¶
func (j *Job) GetDownstreamJobsMetadata() []job
func (*Job) GetFirstBuild ¶
func (*Job) GetInnerJobs ¶
func (*Job) GetInnerJobsMetadata ¶
func (j *Job) GetInnerJobsMetadata() []job
func (*Job) GetLastBuild ¶
func (*Job) GetLastCompletedBuild ¶
func (*Job) GetLastFailedBuild ¶
func (*Job) GetLastStableBuild ¶
func (*Job) GetLastSuccessfulBuild ¶
func (*Job) GetParameters ¶
func (*Job) GetUpstreamJobs ¶
func (*Job) GetUpstreamJobsMetadata ¶
func (j *Job) GetUpstreamJobsMetadata() []job
func (*Job) HasQueuedBuild ¶
func (j *Job) HasQueuedBuild()
func (*Job) UpdateConfig ¶
type Label ¶
type Label struct { Raw *LabelResponse Jenkins *Jenkins Base string }
type LabelResponse ¶
type Node ¶
type Node struct { Raw *NodeResponse Jenkins *Jenkins Base string }
func (*Node) Disconnect ¶
func (*Node) GetLogText ¶
func (*Node) Info ¶
func (n *Node) Info() (*NodeResponse, error)
func (*Node) IsJnlpAgent ¶
func (*Node) IsTemporarilyOffline ¶
func (*Node) LaunchNodeBySSH ¶
func (*Node) SetOffline ¶
func (*Node) ToggleTemporarilyOffline ¶
type NodeResponse ¶
type NodeResponse struct { 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"` }
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"` }
type Requester ¶
func (*Requester) Do ¶
func (r *Requester) Do(ar *APIRequest, responseStruct interface{}, options ...interface{}) (*http.Response, error)
func (*Requester) ReadJSONResponse ¶
func (*Requester) ReadRawResponse ¶
func (*Requester) SetCrumb ¶
func (r *Requester) SetCrumb(ar *APIRequest) error
type Task ¶
func (*Task) GetParameters ¶
func (t *Task) GetParameters() []parameter