warren830 commented on code in PR #4700:
URL:
https://github.com/apache/incubator-devlake/pull/4700#discussion_r1140041005
##########
backend/plugins/jenkins/tasks/build_collector.go:
##########
@@ -55,29 +66,68 @@ func CollectApiBuilds(taskCtx plugin.SubTaskContext)
errors.Error {
Ctx: taskCtx,
Table: RAW_BUILD_TABLE,
},
- ApiClient: data.ApiClient,
- PageSize: 100,
- UrlTemplate: fmt.Sprintf("%sjob/%s/api/json",
data.Options.JobPath, data.Options.JobName),
- /*
- (Optional) Return query string for request, or you can
plug them into UrlTemplate directly
- */
- Query: func(reqData *api.RequestData) (url.Values,
errors.Error) {
- query := url.Values{}
- treeValue := fmt.Sprintf(
-
"allBuilds[number,timestamp,duration,building,estimatedDuration,fullDisplayName,result,actions[lastBuiltRevision[SHA1,branch[name]],remoteUrls,mercurialRevisionNumber,causes[*]],changeSet[kind,revisions[revision]]]{%d,%d}",
- reqData.Pager.Skip,
reqData.Pager.Skip+reqData.Pager.Size)
- query.Set("tree", treeValue)
- return query, nil
+ ApiClient: data.ApiClient,
+ TimeAfter: data.TimeAfter,
+ CollectNewRecordsByList: helper.FinalizableApiCollectorListArgs{
+ PageSize: 100,
+ Concurrency: 10,
+ FinalizableApiCollectorCommonArgs:
helper.FinalizableApiCollectorCommonArgs{
+ UrlTemplate: fmt.Sprintf("%sjob/%s/api/json",
data.Options.JobPath, data.Options.JobName),
+ Query: func(reqData *helper.RequestData,
createdAfter *time.Time) (url.Values, errors.Error) {
+ query := url.Values{}
+ treeValue := fmt.Sprintf(
+
"allBuilds[timestamp,number,duration,building,estimatedDuration,fullDisplayName,result,actions[lastBuiltRevision[SHA1,branch[name]],remoteUrls,mercurialRevisionNumber,causes[*]],changeSet[kind,revisions[revision]]]{%d,%d}",
+ reqData.Pager.Skip,
reqData.Pager.Skip+reqData.Pager.Size)
+ query.Set("tree", treeValue)
+ return query, nil
+ },
+ ResponseParser: func(res *http.Response)
([]json.RawMessage, errors.Error) {
+ var data struct {
+ Builds []json.RawMessage
`json:"allBuilds"`
+ }
+ err := helper.UnmarshalResponse(res,
&data)
+ if err != nil {
+ return nil, err
+ }
+ return data.Builds, nil
+ },
+ },
+ GetCreated: func(item json.RawMessage) (time.Time,
errors.Error) {
+ b := &SimpleJenkinsApiBuild{}
Review Comment:
i think you should add json tag for SimpleJenkinsApiBuild, Then you can get
its'createdDate
--
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]