You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by GitBox <gi...@apache.org> on 2022/06/15 11:39:17 UTC
[GitHub] [incubator-devlake] abeizn opened a new pull request, #2206: feat: multi-data connections support for Jenkins
abeizn opened a new pull request, #2206:
URL: https://github.com/apache/incubator-devlake/pull/2206
Summary
update jenkins/api/connection to load and save through db not .env
update all entities with new field connection_id
update all tasks
add migration scripts
Replace GetDb with GetDal
Remove Concurrency parameter
Does this close any open issues?
related to https://github.com/apache/incubator-devlake/issues/1978
Screenshots
image
image
--
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: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-devlake] warren830 merged pull request #2206: feat: multi-data connections support for Jenkins
Posted by GitBox <gi...@apache.org>.
warren830 merged PR #2206:
URL: https://github.com/apache/incubator-devlake/pull/2206
--
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: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-devlake] warren830 commented on a diff in pull request #2206: feat: multi-data connections support for Jenkins
Posted by GitBox <gi...@apache.org>.
warren830 commented on code in PR #2206:
URL: https://github.com/apache/incubator-devlake/pull/2206#discussion_r898656291
##########
plugins/jenkins/api/connection.go:
##########
@@ -41,7 +38,7 @@ func TestConnection(input *core.ApiResourceInput) (*core.ApiResourceOutput, erro
if err != nil {
return nil, err
}
- // validate
+ // validateplugins/jenkins/tasks/job_collector.go
Review Comment:
this is to validate connection
##########
plugins/jenkins/tasks/build_collector.go:
##########
@@ -70,7 +81,7 @@ func CollectApiBuilds(taskCtx core.SubTaskContext) error {
query := url.Values{}
treeValue := fmt.Sprintf(
"allBuilds[number,timestamp,duration,estimatedDuration,displayName,result,actions[lastBuiltRevision[SHA1],mercurialRevisionNumber],changeSet[kind,revisions[revision]]]{%d,%d}",
- reqData.Pager.Skip, reqData.Pager.Skip+reqData.Pager.Size)
+ reqData.Pager.Skip+1, reqData.Pager.Skip+reqData.Pager.Size)
Review Comment:
we don't need to +1, please check
##########
plugins/jenkins/models/migrationscripts/init_schema.go:
##########
@@ -19,22 +19,73 @@ package migrationscripts
import (
"context"
+ "fmt"
+ "github.com/apache/incubator-devlake/config"
+ "github.com/apache/incubator-devlake/plugins/core"
"github.com/apache/incubator-devlake/plugins/jenkins/models/migrationscripts/archived"
"gorm.io/gorm"
+ "gorm.io/gorm/clause"
)
type InitSchemas struct{}
func (*InitSchemas) Up(ctx context.Context, db *gorm.DB) error {
- return db.Migrator().AutoMigrate(
+
+ rawTableList := []string{
+ "_raw_jenkins_api_jobs",
+ "_raw_jenkins_api_builds",
+ }
+ for _, v := range rawTableList {
+ err := db.Exec(fmt.Sprintf("DROP TABLE IF EXISTS %s CASCADE", v)).Error
+ if err != nil {
+ return err
+ }
+ }
+
+ err := db.Migrator().DropTable(
+ &archived.JenkinsJob{},
+ &archived.JenkinsBuild{},
Review Comment:
we can add string "_raw_jenkins_api_jobs" into DropTable
##########
plugins/jenkins/tasks/job_convertor.go:
##########
@@ -35,30 +37,36 @@ var ConvertJobsMeta = core.SubTaskMeta{
}
func ConvertJobs(taskCtx core.SubTaskContext) error {
- db := taskCtx.GetDb()
-
- jenkinsJob := &models.JenkinsJob{}
+ db := taskCtx.GetDal()
+ data := taskCtx.GetData().(*JenkinsTaskData)
- jobIdGen := didgen.NewDomainIdGenerator(jenkinsJob)
-
- cursor, err := db.Model(jenkinsJob).Rows()
+ clauses := []Clause{
+ Select("*"),
+ From("_tool_jenkins_jobs"),
Review Comment:
connection id
##########
plugins/jenkins/tasks/job_collector.go:
##########
@@ -59,14 +57,15 @@ func CollectApiJobs(taskCtx core.SubTaskContext) error {
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: "api/json",
Query: func(reqData *helper.RequestData) (url.Values, error) {
query := url.Values{}
treeValue := fmt.Sprintf(
"jobs[name,class,color,base]{%d,%d}",
- reqData.Pager.Skip, reqData.Pager.Skip+reqData.Pager.Size)
+ reqData.Pager.Skip+1, reqData.Pager.Skip+reqData.Pager.Size)
Review Comment:
we should not +1
--
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: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org