Documentation
¶
Overview ¶
Gojenkins is a Jenkins Client in Go, that exposes the jenkins REST api in a more developer friendly way.
Index ¶
- Constants
- Variables
- func CheckResponse(r *http.Response) error
- func ParseJenkinsQuery(query string) (result url.Values, err error)
- func Reverse(s string) string
- func UploadFunc(fileName string, writer *multipart.Writer) error
- type APIRequest
- type BasicAuth
- type Branch
- type Build
- func (b *Build) GetBuildNumber() int64
- func (b *Build) GetCauses() ([]map[string]interface{}, error)
- func (b *Build) GetConsoleOutput() string
- func (b *Build) GetDuration() int64
- func (b *Build) GetInjectedEnvVars() (map[string]string, error)
- func (b *Build) GetResult() string
- func (b *Build) GetResultSet() (*TestResult, error)
- func (b *Build) GetRevisionBranch() string
- func (b *Build) GetTimestamp() time.Time
- func (b *Build) GetUrl() string
- func (b *Build) Info() *devops.Build
- func (b *Build) IsGood() bool
- func (b *Build) IsRunning() bool
- func (b *Build) PauseToggle() error
- func (b *Build) Poll(options ...interface{}) (int, error)
- func (b *Build) SetDescription(description string) error
- func (b *Build) Stop() (bool, error)
- type BuildResponse
- type BuildRevision
- type Builds
- type Culprit
- type Folder
- type FolderResponse
- type GeneralObj
- type History
- type InnerJob
- type Jenkins
- func (j *Jenkins) BuildJob(name string, options ...interface{}) (int64, error)
- func (j *Jenkins) CheckCron(projectName string, httpParameters *devops.HttpParameters) (*devops.CheckCronRes, error)
- func (j *Jenkins) CheckPipelineName(projectName, pipelineName string, httpParameters *devops.HttpParameters) (map[string]interface{}, error)
- func (j *Jenkins) CheckScriptCompile(projectName, pipelineName string, httpParameters *devops.HttpParameters) (*devops.CheckScript, error)
- func (j *Jenkins) CopyJob(copyFrom string, newName string) (*Job, error)
- func (j *Jenkins) CreateCredentialInProject(projectId string, credential *v1.Secret) (string, error)
- func (j *Jenkins) CreateDevOpsProject(projectId string) (string, error)
- func (j *Jenkins) CreateFolder(name, description string, parents ...string) (*Folder, error)
- func (j *Jenkins) CreateJob(config string, options ...interface{}) (*Job, error)
- func (j *Jenkins) CreateJobInFolder(config string, jobName string, parentIDs ...string) (*Job, error)
- func (j *Jenkins) CreateProjectPipeline(projectId string, pipeline *devopsv1alpha3.Pipeline) (string, error)
- func (j *Jenkins) CreateSCMServers(scmId string, httpParameters *devops.HttpParameters) (*devops.SCMServer, error)
- func (j *Jenkins) DeleteCredentialInProject(projectId, id string) (string, error)
- func (j *Jenkins) DeleteDevOpsProject(projectId string) (err error)
- func (j *Jenkins) DeleteJob(name string, parentIDs ...string) (bool, error)
- func (j *Jenkins) DeleteProjectPipeline(projectId string, pipelineId string) (string, error)
- func (j *Jenkins) GenericWebhook(httpParameters *devops.HttpParameters) ([]byte, error)
- func (j *Jenkins) GetArtifacts(projectName, pipelineName, runId string, httpParameters *devops.HttpParameters) ([]devops.Artifacts, error)
- func (j *Jenkins) GetBranchArtifacts(projectName, pipelineName, branchName, runId string, ...) ([]devops.Artifacts, error)
- func (j *Jenkins) GetBranchNodeSteps(projectName, pipelineName, branchName, runId, nodeId string, ...) ([]devops.NodeSteps, error)
- func (j *Jenkins) GetBranchPipeline(projectName, pipelineName, branchName string, ...) (*devops.BranchPipeline, error)
- func (j *Jenkins) GetBranchPipelineRun(projectName, pipelineName, branchName, runId string, ...) (*devops.PipelineRun, error)
- func (j *Jenkins) GetBranchPipelineRunNodes(projectName, pipelineName, branchName, runId string, ...) ([]devops.BranchPipelineRunNodes, error)
- func (j *Jenkins) GetBranchRunLog(projectName, pipelineName, branchName, runId string, ...) ([]byte, error)
- func (j *Jenkins) GetBranchStepLog(projectName, pipelineName, branchName, runId, nodeId, stepId string, ...) ([]byte, http.Header, error)
- func (j *Jenkins) GetBuild(jobName string, number int64) (*Build, error)
- func (j *Jenkins) GetConsoleLog(projectName, pipelineName string, httpParameters *devops.HttpParameters) ([]byte, error)
- func (j *Jenkins) GetCredentialInProject(projectId, id string) (*devops.Credential, error)
- func (j *Jenkins) GetCrumb(httpParameters *devops.HttpParameters) (*devops.Crumb, error)
- func (j *Jenkins) GetDevOpsProject(projectId string) (string, error)
- func (j *Jenkins) GetFolder(id string, parents ...string) (*Folder, error)
- func (j *Jenkins) GetJob(id string, parentIDs ...string) (*Job, error)
- func (j *Jenkins) GetMultiBranchPipelineBuildByType(projectId, pipelineId, branch string, status string) (build *devops.Build, err error)
- func (j *Jenkins) GetNodeSteps(projectName, pipelineName, runId, nodeId string, ...) ([]devops.NodeSteps, error)
- func (j *Jenkins) GetNotifyCommit(httpParameters *devops.HttpParameters) ([]byte, error)
- func (j *Jenkins) GetOrgRepo(scmId, organizationId string, httpParameters *devops.HttpParameters) (devops.OrgRepo, error)
- func (j *Jenkins) GetPipeline(projectName, pipelineName string, httpParameters *devops.HttpParameters) (*devops.Pipeline, error)
- func (j *Jenkins) GetPipelineBranch(projectName, pipelineName string, httpParameters *devops.HttpParameters) (*devops.PipelineBranch, error)
- func (j *Jenkins) GetPipelineRun(projectName, pipelineName, runId string, httpParameters *devops.HttpParameters) (*devops.PipelineRun, error)
- func (j *Jenkins) GetPipelineRunNodes(projectName, pipelineName, runId string, httpParameters *devops.HttpParameters) ([]devops.PipelineRunNodes, error)
- func (j *Jenkins) GetProjectPipelineBuildByType(projectId, pipelineId string, status string) (build *devops.Build, err error)
- func (j *Jenkins) GetProjectPipelineConfig(projectId, pipelineId string) (*devopsv1alpha3.Pipeline, error)
- func (j *Jenkins) GetRunLog(projectName, pipelineName, runId string, httpParameters *devops.HttpParameters) ([]byte, error)
- func (j *Jenkins) GetSCMOrg(scmId string, httpParameters *devops.HttpParameters) ([]devops.SCMOrg, error)
- func (j *Jenkins) GetSCMServers(scmId string, httpParameters *devops.HttpParameters) ([]devops.SCMServer, error)
- func (j *Jenkins) GetStepLog(projectName, pipelineName, runId, nodeId, stepId string, ...) ([]byte, http.Header, error)
- func (j *Jenkins) GithubWebhook(httpParameters *devops.HttpParameters) ([]byte, error)
- func (j *Jenkins) Init() (*Jenkins, error)
- func (j *Jenkins) ListPipelineRuns(projectName, pipelineName string, httpParameters *devops.HttpParameters) (*devops.PipelineRunList, error)
- func (j *Jenkins) ListPipelines(httpParameters *devops.HttpParameters) (*devops.PipelineList, error)
- func (j *Jenkins) Poll() (int, error)
- func (j *Jenkins) RenameJob(job string, name string) *Job
- func (j *Jenkins) ReplayBranchPipeline(projectName, pipelineName, branchName, runId string, ...) (*devops.ReplayPipeline, error)
- func (j *Jenkins) ReplayPipeline(projectName, pipelineName, runId string, httpParameters *devops.HttpParameters) (*devops.ReplayPipeline, error)
- func (j *Jenkins) RunBranchPipeline(projectName, pipelineName, branchName string, ...) (*devops.RunPipeline, error)
- func (j *Jenkins) RunPipeline(projectName, pipelineName string, httpParameters *devops.HttpParameters) (*devops.RunPipeline, error)
- func (j *Jenkins) ScanBranch(projectName, pipelineName string, httpParameters *devops.HttpParameters) ([]byte, error)
- func (j *Jenkins) SendPureRequest(path string, httpParameters *devops.HttpParameters) ([]byte, error)
- func (j *Jenkins) SendPureRequestWithHeaderResp(path string, httpParameters *devops.HttpParameters) ([]byte, http.Header, error)
- func (j *Jenkins) StopBranchPipeline(projectName, pipelineName, branchName, runId string, ...) (*devops.StopPipeline, error)
- func (j *Jenkins) StopPipeline(projectName, pipelineName, runId string, httpParameters *devops.HttpParameters) (*devops.StopPipeline, error)
- func (j *Jenkins) SubmitBranchInputStep(projectName, pipelineName, branchName, runId, nodeId, stepId string, ...) ([]byte, error)
- func (j *Jenkins) SubmitInputStep(projectName, pipelineName, runId, nodeId, stepId string, ...) ([]byte, error)
- func (j *Jenkins) UpdateCredentialInProject(projectId string, credential *v1.Secret) (string, error)
- func (j *Jenkins) UpdateProjectPipeline(projectId string, pipeline *devopsv1alpha3.Pipeline) (string, error)
- func (j *Jenkins) Validate(scmId string, httpParameters *devops.HttpParameters) (*devops.Validates, error)
- func (j *Jenkins) ValidateJenkinsfile(jenkinsfile string) (*ValidateJenkinsfileResponse, error)
- func (j *Jenkins) ValidatePipelineJson(json string) (*ValidatePipelineJsonResponse, error)
- type JenkinsBlueTime
- type JkError
- 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) GetAllBuildIds() ([]JobBuild, error)
- func (j *Job) GetAllBuildStatus() ([]JobBuildStatus, 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) GetFirstBuild() (*Build, error)
- 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) HasQueuedBuild()
- 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) 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 JobBuild
- type JobBuildStatus
- type JobResponse
- type Options
- type Parameter
- type ParameterDefinition
- type Pipeline
- func (p *Pipeline) CheckCron() (*devops.CheckCronRes, error)
- func (p *Pipeline) CheckPipelineName() (map[string]interface{}, error)
- func (p *Pipeline) CheckScriptCompile() (*devops.CheckScript, error)
- func (p *Pipeline) CreateSCMServers() (*devops.SCMServer, error)
- func (p *Pipeline) GenericWebhook() ([]byte, error)
- func (p *Pipeline) GetArtifacts() ([]devops.Artifacts, error)
- func (p *Pipeline) GetBranchArtifacts() ([]devops.Artifacts, error)
- func (p *Pipeline) GetBranchNodeSteps() ([]devops.NodeSteps, error)
- func (p *Pipeline) GetBranchPipeline() (*devops.BranchPipeline, error)
- func (p *Pipeline) GetBranchPipelineRun() (*devops.PipelineRun, error)
- func (p *Pipeline) GetBranchPipelineRunNodes() ([]devops.BranchPipelineRunNodes, error)
- func (p *Pipeline) GetBranchRunLog() ([]byte, error)
- func (p *Pipeline) GetBranchStepLog() ([]byte, http.Header, error)
- func (p *Pipeline) GetConsoleLog() ([]byte, error)
- func (p *Pipeline) GetCrumb() (*devops.Crumb, error)
- func (p *Pipeline) GetNodeSteps() ([]devops.NodeSteps, error)
- func (p *Pipeline) GetNotifyCommit() ([]byte, error)
- func (p *Pipeline) GetOrgRepo() (devops.OrgRepo, error)
- func (p *Pipeline) GetPipeline() (*devops.Pipeline, error)
- func (p *Pipeline) GetPipelineBranch() (*devops.PipelineBranch, error)
- func (p *Pipeline) GetPipelineRun() (*devops.PipelineRun, error)
- func (p *Pipeline) GetPipelineRunNodes() ([]devops.PipelineRunNodes, error)
- func (p *Pipeline) GetRunLog() ([]byte, error)
- func (p *Pipeline) GetSCMOrg() ([]devops.SCMOrg, error)
- func (p *Pipeline) GetSCMServers() ([]devops.SCMServer, error)
- func (p *Pipeline) GetStepLog() ([]byte, http.Header, error)
- func (p *Pipeline) GithubWebhook() ([]byte, error)
- func (p *Pipeline) ListPipelineRuns() (*devops.PipelineRunList, error)
- func (p *Pipeline) ListPipelines() (*devops.PipelineList, error)
- func (p *Pipeline) ReplayBranchPipeline() (*devops.ReplayPipeline, error)
- func (p *Pipeline) ReplayPipeline() (*devops.ReplayPipeline, error)
- func (p *Pipeline) RunBranchPipeline() (*devops.RunPipeline, error)
- func (p *Pipeline) RunPipeline() (*devops.RunPipeline, error)
- func (p *Pipeline) ScanBranch() ([]byte, error)
- func (p *Pipeline) StopBranchPipeline() (*devops.StopPipeline, error)
- func (p *Pipeline) StopPipeline() (*devops.StopPipeline, error)
- func (p *Pipeline) SubmitBranchInputStep() ([]byte, error)
- func (p *Pipeline) SubmitInputStep() ([]byte, error)
- func (p *Pipeline) ToJSON() (result map[string]interface{}, err error)
- func (p *Pipeline) ToJenkinsfile() (*devops.ResJenkinsfile, error)
- func (p *Pipeline) Validate() (*devops.Validates, error)
- type Requester
- func (r *Requester) Do(ar *APIRequest, responseStruct interface{}, options ...interface{}) (*http.Response, error)
- func (r *Requester) DoGet(ar *APIRequest, responseStruct interface{}, options ...interface{}) (*http.Response, error)
- func (r *Requester) DoPostForm(ar *APIRequest, responseStruct interface{}, form map[string]string) (*http.Response, error)
- func (r *Requester) Get(endpoint string, responseStruct interface{}, querystring map[string]string) (*http.Response, error)
- func (r *Requester) GetHtml(endpoint string, responseStruct interface{}, querystring map[string]string) (*http.Response, error)
- func (r *Requester) GetJSON(endpoint string, responseStruct interface{}, query map[string]string) (*http.Response, error)
- func (r *Requester) GetXML(endpoint string, responseStruct interface{}, query 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) PostForm(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
- func (r *Requester) SetCrumbForConsumer(crumbConsumer func(crumbRequestField, crumb string)) error
- type TestResult
- type ValidateJenkinsfileResponse
- type ValidatePipelineJsonResponse
Constants ¶
const ( Git = "git" Hg = "hg" Svn = "svc" )
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 ( GLOBAL_ROLE = "globalRoles" PROJECT_ROLE = "projectRoles" )
const ( StringNull = "" FlowTag = "flow-definition" PropertiesTag = "properties" DisableConcurrentJobTag = "org.jenkinsci.plugins.workflow.job.properties.DisableConcurrentBuildsJobProperty" BuildDiscarderTag = "jenkins.model.BuildDiscarderProperty" StrategyTag = "strategy" DaysToKeepTag = "daysToKeep" NumToKeepTag = "numToKeep" ArtiDaysToKeepTag = "artifactDaysToKeep" ArtiNumToKeepTag = "artifactNumToKeep" ParamDefiPropTag = "hudson.model.ParametersDefinitionProperty" ParamDefiTag = "parameterDefinitions" PipelineTriggersJobTag = "org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty" TriggersTag = "triggers" TimerTriggerTag = "hudson.triggers.TimerTrigger" DefinitionTag = "definition" ClassKey = "class" PluginKey = "plugin" ScriptTag = "script" SandboxTag = "sandbox" AuthTokenTag = "authToken" DisabledTag = "disabled" )
const ( GetPipelineUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/" ListPipelinesUrl = "/blue/rest/search/?" GetPipelineRunUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/%s/" ListPipelineRunUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/?" StopPipelineUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/%s/stop/?" ReplayPipelineUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/%s/replay/" RunPipelineUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/" GetArtifactsUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/%s/artifacts/?" GetRunLogUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/%s/log/?" GetStepLogUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/%s/nodes/%s/steps/%s/log/?" GetPipelineRunNodesUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/%s/nodes/?" SubmitInputStepUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/%s/nodes/%s/steps/%s/" GetNodeStepsUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/%s/nodes/%s/steps/?" GetBranchPipelineUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/" GetBranchPipelineRunUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/runs/%s/" StopBranchPipelineUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/runs/%s/stop/?" ReplayBranchPipelineUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/runs/%s/replay/" RunBranchPipelineUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/runs/" GetBranchArtifactsUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/runs/%s/artifacts/?" GetBranchRunLogUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/runs/%s/log/?" GetBranchStepLogUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/runs/%s/nodes/%s/steps/%s/log/?" GetBranchNodeStepsUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/runs/%s/nodes/%s/steps/?" GetBranchPipeRunNodesUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/runs/%s/nodes/?" CheckBranchPipelineUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/runs/%s/nodes/%s/steps/%s/" GetPipeBranchUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/?" ScanBranchUrl = "/job/%s/job/%s/build?" GetConsoleLogUrl = "/job/%s/job/%s/indexing/consoleText" GetCrumbUrl = "/crumbIssuer/api/json/" GetSCMServersUrl = "/blue/rest/organizations/jenkins/scm/%s/servers/" GetSCMOrgUrl = "/blue/rest/organizations/jenkins/scm/%s/organizations/?" GetOrgRepoUrl = "/blue/rest/organizations/jenkins/scm/%s/organizations/%s/repositories/?" CreateSCMServersUrl = "/blue/rest/organizations/jenkins/scm/%s/servers/" ValidateUrl = "/blue/rest/organizations/jenkins/scm/%s/validate" GetNotifyCommitUrl = "/git/notifyCommit/?" GithubWebhookUrl = "/github-webhook/" // GenericWebhookUrl comes from Jenkins plugin, see also https://github.com/jenkinsci/generic-webhook-trigger-plugin GenericWebhookUrl = "/generic-webhook-trigger/invoke?" CheckScriptCompileUrl = "/job/%s/job/%s/descriptorByName/org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition/checkScriptCompile" CheckPipelienCronUrl = "/job/%s/job/%s/descriptorByName/hudson.triggers.TimerTrigger/checkSpec?%s" CheckCronUrl = "/job/%s/descriptorByName/hudson.triggers.TimerTrigger/checkSpec?%s" CheckPipelineName = "/job/%s/checkJobName?" )
Variables ¶
Loggers
var ParameterTypeMap = map[string]string{
"hudson.model.StringParameterDefinition": "string",
"hudson.model.ChoiceParameterDefinition": "choice",
"hudson.model.TextParameterDefinition": "text",
"hudson.model.BooleanParameterDefinition": "boolean",
"hudson.model.FileParameterDefinition": "file",
"hudson.model.PasswordParameterDefinition": "password",
}
ParameterTypeMap aims for simplifying representation of parameter definition type.
Functions ¶
func CheckResponse ¶
func ParseJenkinsQuery ¶
ParseJenkinsQuery Parse the special query of jenkins. ParseQuery in the standard library makes the query not re-encode
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 Build ¶
func (*Build) GetBuildNumber ¶
func (*Build) GetConsoleOutput ¶
func (*Build) GetDuration ¶
func (*Build) GetResultSet ¶
func (b *Build) GetResultSet() (*TestResult, error)
func (*Build) GetRevisionBranch ¶
func (*Build) GetTimestamp ¶
func (*Build) PauseToggle ¶
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 BuildResponse ¶
type BuildResponse struct {
Actions []devops.GeneralAction
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"`
Culprits []devops.Culprit `json:"culprits"`
Description interface{} `json:"description"`
Duration int64 `json:"duration"`
EstimatedDuration int64 `json:"estimatedDuration"`
Executor interface{} `json:"executor"`
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"`
Runs []struct {
Number int64
URL string
} `json:"runs"`
}
type BuildRevision ¶
type Builds ¶
type Builds struct {
BuildNumber int64 `json:"buildNumber"`
BuildResult interface{} `json:"buildResult"`
Marked BuildRevision `json:"marked"`
Revision BuildRevision `json:"revision"`
}
type Folder ¶
type Folder struct {
Raw *FolderResponse
Jenkins *Jenkins
Base string
}
type FolderResponse ¶
type GeneralObj ¶
type GeneralObj struct {
Parameters []Parameter `json:"parameters,omitempty"`
Causes []map[string]interface{} `json:"causes,omitempty"`
BuildsByBranchName map[string]Builds `json:"buildsByBranchName,omitempty"`
LastBuiltRevision *BuildRevision `json:"lastBuiltRevision,omitempty"`
RemoteUrls []string `json:"remoteUrls,omitempty"`
ScmName string `json:"scmName,omitempty"`
MercurialNodeName string `json:"mercurialNodeName,omitempty"`
MercurialRevisionNumber string `json:"mercurialRevisionNumber,omitempty"`
Subdir interface{} `json:"subdir,omitempty"`
ClassName string `json:"_class,omitempty"`
SonarTaskId string `json:"ceTaskId,omitempty"`
SonarServerUrl string `json:"serverUrl,omitempty"`
SonarDashboardUrl string `json:"sonarqubeDashboardUrl,omitempty"`
TotalCount int64 `json:",omitempty"`
UrlName string `json:",omitempty"`
}
type Jenkins ¶
func CreateJenkins ¶
func CreateJenkins(client *http.Client, base string, maxConnection int, auth ...interface{}) *Jenkins
Creates a new Jenkins Instance Optional parameters are: client, username, password After creating an instance call init method.
func NewDevopsClient ¶
func (*Jenkins) BuildJob ¶
Invoke a job. First Parameter job name, second Parameter is optional Build parameters.
func (*Jenkins) CheckCron ¶
func (j *Jenkins) CheckCron(projectName string, httpParameters *devops.HttpParameters) (*devops.CheckCronRes, error)
func (*Jenkins) CheckPipelineName ¶
func (*Jenkins) CheckScriptCompile ¶
func (j *Jenkins) CheckScriptCompile(projectName, pipelineName string, httpParameters *devops.HttpParameters) (*devops.CheckScript, error)
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) CreateCredentialInProject ¶
func (*Jenkins) CreateDevOpsProject ¶
func (*Jenkins) CreateFolder ¶
Create a new folder This folder can be nested in other parent folders Example: jenkins.CreateFolder("newFolder", "grandparentFolder", "parentFolder")
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) CreateJobInFolder ¶
func (j *Jenkins) CreateJobInFolder(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) CreateProjectPipeline ¶
func (*Jenkins) CreateSCMServers ¶
func (*Jenkins) DeleteDevOpsProject ¶
func (*Jenkins) DeleteProjectPipeline ¶
func (*Jenkins) GenericWebhook ¶
func (j *Jenkins) GenericWebhook(httpParameters *devops.HttpParameters) ([]byte, error)
func (*Jenkins) GetArtifacts ¶
func (*Jenkins) GetBranchArtifacts ¶
func (*Jenkins) GetBranchNodeSteps ¶
func (*Jenkins) GetBranchPipeline ¶
func (j *Jenkins) GetBranchPipeline(projectName, pipelineName, branchName string, httpParameters *devops.HttpParameters) (*devops.BranchPipeline, error)
func (*Jenkins) GetBranchPipelineRun ¶
func (j *Jenkins) GetBranchPipelineRun(projectName, pipelineName, branchName, runId string, httpParameters *devops.HttpParameters) (*devops.PipelineRun, error)
func (*Jenkins) GetBranchPipelineRunNodes ¶
func (j *Jenkins) GetBranchPipelineRunNodes(projectName, pipelineName, branchName, runId string, httpParameters *devops.HttpParameters) ([]devops.BranchPipelineRunNodes, error)
func (*Jenkins) GetBranchRunLog ¶
func (*Jenkins) GetBranchStepLog ¶
func (*Jenkins) GetConsoleLog ¶
func (*Jenkins) GetCredentialInProject ¶
func (j *Jenkins) GetCredentialInProject(projectId, id string) (*devops.Credential, error)
func (*Jenkins) GetDevOpsProject ¶
func (*Jenkins) GetMultiBranchPipelineBuildByType ¶
func (*Jenkins) GetNodeSteps ¶
func (*Jenkins) GetNotifyCommit ¶
func (j *Jenkins) GetNotifyCommit(httpParameters *devops.HttpParameters) ([]byte, error)
func (*Jenkins) GetOrgRepo ¶
func (*Jenkins) GetPipeline ¶
func (*Jenkins) GetPipelineBranch ¶
func (j *Jenkins) GetPipelineBranch(projectName, pipelineName string, httpParameters *devops.HttpParameters) (*devops.PipelineBranch, error)
func (*Jenkins) GetPipelineRun ¶
func (j *Jenkins) GetPipelineRun(projectName, pipelineName, runId string, httpParameters *devops.HttpParameters) (*devops.PipelineRun, error)
func (*Jenkins) GetPipelineRunNodes ¶
func (j *Jenkins) GetPipelineRunNodes(projectName, pipelineName, runId string, httpParameters *devops.HttpParameters) ([]devops.PipelineRunNodes, error)
func (*Jenkins) GetProjectPipelineBuildByType ¶
func (*Jenkins) GetProjectPipelineConfig ¶
func (j *Jenkins) GetProjectPipelineConfig(projectId, pipelineId string) (*devopsv1alpha3.Pipeline, error)
func (*Jenkins) GetSCMServers ¶
func (*Jenkins) GetStepLog ¶
func (*Jenkins) GithubWebhook ¶
func (j *Jenkins) GithubWebhook(httpParameters *devops.HttpParameters) ([]byte, error)
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.
func (*Jenkins) ListPipelineRuns ¶
func (j *Jenkins) ListPipelineRuns(projectName, pipelineName string, httpParameters *devops.HttpParameters) (*devops.PipelineRunList, error)
func (*Jenkins) ListPipelines ¶
func (j *Jenkins) ListPipelines(httpParameters *devops.HttpParameters) (*devops.PipelineList, error)
func (*Jenkins) RenameJob ¶
Rename a job. First Parameter job old name, Second Parameter job new name.
func (*Jenkins) ReplayBranchPipeline ¶
func (j *Jenkins) ReplayBranchPipeline(projectName, pipelineName, branchName, runId string, httpParameters *devops.HttpParameters) (*devops.ReplayPipeline, error)
func (*Jenkins) ReplayPipeline ¶
func (j *Jenkins) ReplayPipeline(projectName, pipelineName, runId string, httpParameters *devops.HttpParameters) (*devops.ReplayPipeline, error)
func (*Jenkins) RunBranchPipeline ¶
func (j *Jenkins) RunBranchPipeline(projectName, pipelineName, branchName string, httpParameters *devops.HttpParameters) (*devops.RunPipeline, error)
func (*Jenkins) RunPipeline ¶
func (j *Jenkins) RunPipeline(projectName, pipelineName string, httpParameters *devops.HttpParameters) (*devops.RunPipeline, error)
func (*Jenkins) ScanBranch ¶
func (*Jenkins) SendPureRequest ¶
func (j *Jenkins) SendPureRequest(path string, httpParameters *devops.HttpParameters) ([]byte, error)
TODO: deprecated, use SendJenkinsRequestWithHeaderResp() instead
func (*Jenkins) SendPureRequestWithHeaderResp ¶
func (j *Jenkins) SendPureRequestWithHeaderResp(path string, httpParameters *devops.HttpParameters) ([]byte, http.Header, error)
SendPureRequestWithHeaderResp provider request header to call jenkins api. transfer bearer token to basic token for inner Oauth and Jenkins
func (*Jenkins) StopBranchPipeline ¶
func (j *Jenkins) StopBranchPipeline(projectName, pipelineName, branchName, runId string, httpParameters *devops.HttpParameters) (*devops.StopPipeline, error)
func (*Jenkins) StopPipeline ¶
func (j *Jenkins) StopPipeline(projectName, pipelineName, runId string, httpParameters *devops.HttpParameters) (*devops.StopPipeline, error)
func (*Jenkins) SubmitBranchInputStep ¶
func (*Jenkins) SubmitInputStep ¶
func (*Jenkins) UpdateCredentialInProject ¶
func (*Jenkins) UpdateProjectPipeline ¶
func (*Jenkins) ValidateJenkinsfile ¶
func (j *Jenkins) ValidateJenkinsfile(jenkinsfile string) (*ValidateJenkinsfileResponse, error)
func (*Jenkins) ValidatePipelineJson ¶
func (j *Jenkins) ValidatePipelineJson(json string) (*ValidatePipelineJsonResponse, error)
type JenkinsBlueTime ¶
func (JenkinsBlueTime) MarshalJSON ¶
func (t JenkinsBlueTime) MarshalJSON() ([]byte, error)
func (*JenkinsBlueTime) UnmarshalJSON ¶
func (t *JenkinsBlueTime) UnmarshalJSON(b []byte) error
type Job ¶
type Job struct {
Raw *JobResponse
Jenkins *Jenkins
Base string
}
func (*Job) GetAllBuildIds ¶
Returns All Builds with Number and URL
func (*Job) GetAllBuildStatus ¶
func (j *Job) GetAllBuildStatus() ([]JobBuildStatus, error)
func (*Job) GetDescription ¶
func (*Job) GetDetails ¶
func (j *Job) GetDetails() *JobResponse
func (*Job) GetFirstBuild ¶
func (*Job) GetLastBuild ¶
func (*Job) GetLastCompletedBuild ¶
func (*Job) GetLastFailedBuild ¶
func (*Job) GetLastStableBuild ¶
func (*Job) GetLastSuccessfulBuild ¶
func (*Job) GetParameters ¶
func (j *Job) GetParameters() ([]ParameterDefinition, error)
func (*Job) HasQueuedBuild ¶
func (j *Job) HasQueuedBuild()
func (*Job) UpdateConfig ¶
type JobBuildStatus ¶
type JobResponse ¶
type JobResponse struct {
Class string `json:"_class"`
Actions []devops.GeneralAction
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
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"`
SubJobs []InnerJob `json:"subJobs"`
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"`
}
type Options ¶
type Options struct {
Host string `json:",omitempty" yaml:"host" description:"Jenkins service host address"`
Username string `json:",omitempty" yaml:"username" description:"Jenkins admin username"`
Password string `json:",omitempty" yaml:"password" description:"Jenkins admin password"`
ApiToken string `json:"apiToken,omitempty" yaml:"apiToken" description:"Jenkins admin apiToken"`
MaxConnections int `json:"maxConnections,omitempty" yaml:"maxConnections" description:"Maximum connections allowed to connect to Jenkins"`
Namespace string `json:"namespace,omitempty" yaml:"namespace"`
WorkerNamespace string `json:"workerNamespace,omitempty" yaml:"workerNamespace"`
ReloadCasCDelay time.Duration `json:"reloadCasCDelay,omitempty" yaml:"reloadCasCDelay"`
SkipVerify bool
SaveKubeConfigAs string `json:"saveKubeConfigAs,omitempty" yaml:"saveKubeConfigAs"` // values: [secret-text, kubeconfig]. default is kubeconfig
}
func NewJenkinsOptions ¶
func NewJenkinsOptions() *Options
NewJenkinsOptions returns a `zero` instance
type ParameterDefinition ¶
type Pipeline ¶
type Pipeline struct {
HttpParameters *devops.HttpParameters
Jenkins *Jenkins
Path string
}
func (*Pipeline) CheckPipelineName ¶
func (*Pipeline) CheckScriptCompile ¶
func (p *Pipeline) CheckScriptCompile() (*devops.CheckScript, error)
func (*Pipeline) CreateSCMServers ¶
func (*Pipeline) GenericWebhook ¶
func (*Pipeline) GetBranchArtifacts ¶
func (*Pipeline) GetBranchNodeSteps ¶
func (*Pipeline) GetBranchPipeline ¶
func (p *Pipeline) GetBranchPipeline() (*devops.BranchPipeline, error)
func (*Pipeline) GetBranchPipelineRun ¶
func (p *Pipeline) GetBranchPipelineRun() (*devops.PipelineRun, error)
func (*Pipeline) GetBranchPipelineRunNodes ¶
func (p *Pipeline) GetBranchPipelineRunNodes() ([]devops.BranchPipelineRunNodes, error)
func (*Pipeline) GetBranchRunLog ¶
func (*Pipeline) GetBranchStepLog ¶
func (*Pipeline) GetConsoleLog ¶
func (*Pipeline) GetNotifyCommit ¶
func (*Pipeline) GetPipelineBranch ¶
func (p *Pipeline) GetPipelineBranch() (*devops.PipelineBranch, error)
func (*Pipeline) GetPipelineRun ¶
func (p *Pipeline) GetPipelineRun() (*devops.PipelineRun, error)
func (*Pipeline) GetPipelineRunNodes ¶
func (p *Pipeline) GetPipelineRunNodes() ([]devops.PipelineRunNodes, error)
func (*Pipeline) GithubWebhook ¶
func (*Pipeline) ListPipelineRuns ¶
func (p *Pipeline) ListPipelineRuns() (*devops.PipelineRunList, error)
func (*Pipeline) ListPipelines ¶
func (p *Pipeline) ListPipelines() (*devops.PipelineList, error)
func (*Pipeline) ReplayBranchPipeline ¶
func (p *Pipeline) ReplayBranchPipeline() (*devops.ReplayPipeline, error)
func (*Pipeline) ReplayPipeline ¶
func (p *Pipeline) ReplayPipeline() (*devops.ReplayPipeline, error)
func (*Pipeline) RunBranchPipeline ¶
func (p *Pipeline) RunBranchPipeline() (*devops.RunPipeline, error)
func (*Pipeline) RunPipeline ¶
func (p *Pipeline) RunPipeline() (*devops.RunPipeline, error)
func (*Pipeline) ScanBranch ¶
func (*Pipeline) StopBranchPipeline ¶
func (p *Pipeline) StopBranchPipeline() (*devops.StopPipeline, error)
func (*Pipeline) StopPipeline ¶
func (p *Pipeline) StopPipeline() (*devops.StopPipeline, error)
func (*Pipeline) SubmitBranchInputStep ¶
func (*Pipeline) SubmitInputStep ¶
func (*Pipeline) ToJenkinsfile ¶
func (p *Pipeline) ToJenkinsfile() (*devops.ResJenkinsfile, error)
type Requester ¶
type Requester struct {
Base string
BasicAuth *BasicAuth
Client *http.Client
CACert []byte
SslVerify bool
// contains filtered or unexported fields
}
func (*Requester) Do ¶
func (r *Requester) Do(ar *APIRequest, responseStruct interface{}, options ...interface{}) (*http.Response, error)
func (*Requester) DoGet ¶
func (r *Requester) DoGet(ar *APIRequest, responseStruct interface{}, options ...interface{}) (*http.Response, error)
func (*Requester) DoPostForm ¶
func (*Requester) ReadJSONResponse ¶
func (*Requester) ReadRawResponse ¶
func (*Requester) SetCrumb ¶
func (r *Requester) SetCrumb(ar *APIRequest) error
func (*Requester) SetCrumbForConsumer ¶
SetCrumbForConsumer makes crumb consumer set the crumb. Crumb consumer accepts crumb request field and crumb parameters and can handle the crumb whatever it likes.
type TestResult ¶
type TestResult struct {
Duration int64 `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 int64 `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 int64 `json:"duration"`
ID interface{} `json:"id"`
Name string `json:"name"`
Stderr interface{} `json:"stderr"`
Stdout interface{} `json:"stdout"`
Timestamp interface{} `json:"timestamp"`
} `json:"suites"`
}