likyh commented on code in PR #3700:
URL:
https://github.com/apache/incubator-devlake/pull/3700#discussion_r1017778760
##########
plugins/jenkins/tasks/job_collector.go:
##########
@@ -40,68 +37,29 @@ var CollectApiJobsMeta = core.SubTaskMeta{
}
func CollectApiJobs(taskCtx core.SubTaskContext) errors.Error {
- it := helper.NewQueueIterator()
- it.Push(models.NewFolderInput(""))
data := taskCtx.GetData().(*JenkinsTaskData)
- incremental := false
collector, err := helper.NewApiCollector(helper.ApiCollectorArgs{
RawDataSubTaskArgs: helper.RawDataSubTaskArgs{
Params: JenkinsApiParams{
ConnectionId: data.Options.ConnectionId,
+ JobName: data.Options.JobName,
+ JobPath: data.Options.JobPath,
},
Ctx: taskCtx,
Table: RAW_JOB_TABLE,
},
ApiClient: data.ApiClient,
- PageSize: 100,
- Incremental: incremental,
- // jenkins api is special, 1. If the concurrency is larger than
1, then it will report 500.
- Concurrency: 1,
-
- UrlTemplate: "{{ .Input.Path }}api/json",
- Input: it,
- Query: func(reqData *helper.RequestData) (url.Values,
errors.Error) {
- query := url.Values{}
- treeValue := fmt.Sprintf(
-
"jobs[name,class,url,color,base,jobs,upstreamProjects[name]]{%d,%d}",
- reqData.Pager.Skip,
reqData.Pager.Skip+reqData.Pager.Size)
- query.Set("tree", treeValue)
- return query, nil
- },
- Header: func(reqData *helper.RequestData) (http.Header,
errors.Error) {
- input, ok := reqData.Input.(*models.FolderInput)
- if ok {
- return http.Header{
- "Path": {
- input.Path,
- },
- }, nil
- } else {
- return nil, errors.Default.New("empty
FolderInput")
- }
- },
-
+ UrlTemplate: "{{ .Params.JobPath }}job/{{ .Params.JobName
}}/api/json",
Review Comment:
add some logic before all subtask to allow `.Params.JobPath` needn't end
with `/`.
The user may don't know what JobPath's format is.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]