Documentation
¶
Index ¶
- Constants
- type JenkinsBuild
- type JenkinsBuildResponse
- type JenkinsJob
- type JenkinsJobResponse
- type Source
- func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk, ...) error
- func (s *Source) Enumerate(ctx context.Context, reporter sources.UnitReporter) error
- func (s *Source) GetJenkinsBuilds(ctx context.Context, jobAbsolutePath string) (JenkinsBuildResponse, error)
- func (s *Source) GetJenkinsJobs(ctx context.Context) (JenkinsJobResponse, error)
- func (s *Source) GetJenkinsObjectsForPath(ctx context.Context, absolutePath string) (JenkinsJobResponse, error)
- func (s *Source) Init(aCtx context.Context, name string, jobId sources.JobID, ...) error
- func (s *Source) JobID() sources.JobID
- func (s *Source) NewRequest(ctx context.Context, method, url string, body io.Reader) (*http.Request, error)
- func (s *Source) RecursivelyGetJenkinsObjectsForPath(ctx context.Context, absolutePath string) (JenkinsJobResponse, error)
- func (s *Source) SourceID() sources.SourceID
- func (s *Source) Type() sourcespb.SourceType
- func (s *Source) UnmarshalSourceUnit(data []byte) (sources.SourceUnit, error)
Constants ¶
const (
SourceType = sourcespb.SourceType_SOURCE_TYPE_JENKINS
)
const SourceUnitKindJob sources.SourceUnitKind = "job"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JenkinsBuild ¶
type JenkinsBuildResponse ¶
type JenkinsBuildResponse struct {
Builds []JenkinsBuild `json:"builds"`
}
type JenkinsJob ¶ added in v3.97.2
type JenkinsJob struct {
Class string `json:"_class"`
Name string `json:"name"`
Url string `json:"url"`
// Path is the job's path relative to the Jenkins instance. Jenkins reports
// absolute job URLs whose host comes from the instance's own root URL
// setting, which can differ from the endpoint being scanned, so only the
// path is retained as the identity. Chunks does the same when it scans a
// job. Path is not part of the Jenkins API response; walkJobs derives it
// from Url, so it is empty on a value decoded straight from a listing.
Path string `json:"path"`
}
JenkinsJob is a job as listed by the Jenkins API, and is the source unit the Jenkins source enumerates.
func (JenkinsJob) Display ¶ added in v3.97.2
func (j JenkinsJob) Display() string
Display returns the job's folder path without the "job" segments Jenkins interleaves, e.g. /jenkins/job/folder1/job/build becomes folder1/build. It is derived from Path rather than from Name so that a unit rebuilt from its ID alone still renders a name.
func (JenkinsJob) SourceUnitID ¶ added in v3.97.2
func (j JenkinsJob) SourceUnitID() (string, sources.SourceUnitKind)
type JenkinsJobResponse ¶
type JenkinsJobResponse struct {
Jobs []JenkinsJob `json:"jobs"`
}
type Source ¶
func (*Source) Chunks ¶
func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk, _ ...sources.ChunkingTarget) error
Chunks emits chunks of bytes over a channel.
func (*Source) Enumerate ¶ added in v3.97.2
Enumerate implements the SourceUnitEnumerator interface. It reports one unit per Jenkins job, walking folders recursively. A folder that cannot be listed is reported to the UnitReporter and the rest of the walk continues.
func (*Source) GetJenkinsBuilds ¶
func (*Source) GetJenkinsJobs ¶
func (s *Source) GetJenkinsJobs(ctx context.Context) (JenkinsJobResponse, error)
GetJenkinsJobs traverses the tree to find all jobs. Example response from http://localhost:8080/api/json?tree=jobs[name,url]{0,100} on our Jenkins instance:
{
"_class": "hudson.model.Hudson",
"jobs": [
{
"_class": "com.cloudbees.hudson.plugins.folder.Folder",
"name": "folder1",
"url": "http://jenkins:8080/job/folder1/"
},
{
"_class": "org.jenkinsci.plugins.workflow.job.WorkflowJob",
"name": "hon-test",
"url": "http://jenkins:8080/job/hon-test/"
},
{
"_class": "hudson.model.FreeStyleProject",
"name": "hon-test-project",
"url": "http://jenkins:8080/job/hon-test-project/"
},
{
"_class": "hudson.model.FreeStyleProject",
"name": "steeeve-freestyle-project",
"url": "http://jenkins:8080/job/steeeve-freestyle-project/"
}
]
}
func (*Source) GetJenkinsObjectsForPath ¶
func (*Source) Init ¶
func (s *Source) Init(aCtx context.Context, name string, jobId sources.JobID, sourceId sources.SourceID, verify bool, connection *anypb.Any, _ int) error
Init returns an initialized Jenkins source.
func (*Source) NewRequest ¶
func (*Source) RecursivelyGetJenkinsObjectsForPath ¶
func (*Source) Type ¶
func (s *Source) Type() sourcespb.SourceType
Type returns the type of source. It is used for matching source types in configuration and job input.
func (*Source) UnmarshalSourceUnit ¶ added in v3.97.2
func (s *Source) UnmarshalSourceUnit(data []byte) (sources.SourceUnit, error)
UnmarshalSourceUnit implements the SourceUnitUnmarshaller interface. It accepts three shapes: the persisted envelope carrying unit_data (round-trips the unit exactly), the envelope without unit_data (rebuilt from id), and a bare JenkinsJob.