MCPcopy Create free account
hub / github.com/apache/devlake / listJenkinsRemoteScopes

Function listJenkinsRemoteScopes

backend/plugins/jenkins/api/remote_api.go:38–94  ·  view source on GitHub ↗
(
	connection *models.JenkinsConnection,
	apiClient plugin.ApiClient,
	groupId string,
	page JenkinsRemotePagination,
)

Source from the content-addressed store, hash-verified

36var scopesWithJobs = []string{"org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject"}
37
38func listJenkinsRemoteScopes(
39 connection *models.JenkinsConnection,
40 apiClient plugin.ApiClient,
41 groupId string,
42 page JenkinsRemotePagination,
43) (
44 children []dsmodels.DsRemoteApiScopeListEntry[models.JenkinsJob],
45 nextPage *JenkinsRemotePagination,
46 err errors.Error,
47) {
48 if page.Page == 0 {
49 page.Page = 1
50 }
51 if page.PerPage == 0 {
52 page.PerPage = 100
53 }
54 var parentId *string
55 if groupId != "" {
56 parentId = &groupId
57 }
58 getJobsPageCallBack := func(job *models.Job) errors.Error {
59 if isGroup(job) {
60 // This is a group
61 job.Path = groupId
62 children = append(children, dsmodels.DsRemoteApiScopeListEntry[models.JenkinsJob]{
63 Type: api.RAS_ENTRY_TYPE_GROUP,
64 Id: fmt.Sprintf("%s/job/%s", job.Path, job.Name),
65 Name: job.Name,
66 ParentId: parentId,
67 })
68 } else {
69 // This is a scope
70 jenkinsJob := job.ToJenkinsJob()
71 children = append(children, dsmodels.DsRemoteApiScopeListEntry[models.JenkinsJob]{
72 Type: api.RAS_ENTRY_TYPE_SCOPE,
73 Id: jenkinsJob.ScopeId(),
74 Name: jenkinsJob.ScopeName(),
75 FullName: jenkinsJob.ScopeFullName(),
76 Data: jenkinsJob,
77 ParentId: parentId,
78 })
79 }
80
81 return nil
82 }
83 _, err = GetJobsPage(apiClient, groupId, page.Page-1, page.PerPage, getJobsPageCallBack)
84 if err != nil {
85 return
86 }
87 if len(children) == page.PerPage {
88 nextPage = &JenkinsRemotePagination{
89 Page: page.Page + 1,
90 PerPage: page.PerPage,
91 }
92 }
93 return
94}
95

Callers

nothing calls this directly

Calls 6

isGroupFunction · 0.85
GetJobsPageFunction · 0.85
ToJenkinsJobMethod · 0.80
ScopeIdMethod · 0.65
ScopeNameMethod · 0.65
ScopeFullNameMethod · 0.65

Tested by

no test coverage detected