This is an automated email from the ASF dual-hosted git repository.

zhangliang2022 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new 927db4240 refactor: rename transformation rule to scope config - jira 
(#5316)
927db4240 is described below

commit 927db42404f393557b26982761c70b06f462d0da
Author: Klesh Wong <[email protected]>
AuthorDate: Wed May 31 11:52:50 2023 +0800

    refactor: rename transformation rule to scope config - jira (#5316)
    
    * refactor: rename transformation rule to scope config - jira
    
    * fix: jira unit test failed after scopeConfig refactor
---
 backend/plugins/jira/api/blueprint_v100.go         | 64 -----------------
 backend/plugins/jira/api/blueprint_v200.go         | 40 +++++++++--
 backend/plugins/jira/api/blueprint_v200_test.go    | 26 ++++---
 backend/plugins/jira/api/init.go                   | 10 +--
 backend/plugins/jira/api/scope.go                  |  2 +-
 .../{transformation_rule.go => scope_config.go}    | 84 +++++++++++-----------
 backend/plugins/jira/api/swagger.go                | 42 ++---------
 backend/plugins/jira/e2e/epic_test.go              |  9 +--
 backend/plugins/jira/e2e/issue_repo_commit_test.go |  5 +-
 backend/plugins/jira/e2e/issue_test.go             |  2 +-
 backend/plugins/jira/e2e/remotelink_test.go        |  5 +-
 backend/plugins/jira/impl/impl.go                  | 37 +++++-----
 backend/plugins/jira/models/board.go               |  2 +-
 ...22_add_connection_id_to_transformation_rules.go | 23 ++++--
 .../migrationscripts/20230530_scope_config.go      | 56 +++++++++++++++
 .../jira/models/migrationscripts/register.go       |  1 +
 .../{transformation_rules.go => scope_config.go}   | 10 +--
 backend/plugins/jira/tasks/issue_extractor.go      |  8 +--
 .../jira/tasks/issue_repo_commit_convertor.go      |  4 +-
 backend/plugins/jira/tasks/remotelink_extractor.go | 11 +--
 backend/plugins/jira/tasks/task_data.go            | 31 ++++----
 backend/plugins/jira/tasks/task_data_test.go       | 20 +++---
 22 files changed, 252 insertions(+), 240 deletions(-)

diff --git a/backend/plugins/jira/api/blueprint_v100.go 
b/backend/plugins/jira/api/blueprint_v100.go
deleted file mode 100644
index a3bc93b0c..000000000
--- a/backend/plugins/jira/api/blueprint_v100.go
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package api
-
-import (
-       "encoding/json"
-       "github.com/apache/incubator-devlake/core/errors"
-       "github.com/apache/incubator-devlake/core/plugin"
-       helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
-       "github.com/apache/incubator-devlake/plugins/jira/tasks"
-)
-
-func MakePipelinePlanV100(subtaskMetas []plugin.SubTaskMeta, connectionId 
uint64, scope []*plugin.BlueprintScopeV100) (plugin.PipelinePlan, errors.Error) 
{
-       var err errors.Error
-       plan := make(plugin.PipelinePlan, len(scope))
-       for i, scopeElem := range scope {
-               var transformationRules tasks.JiraTransformationRule
-               if len(scopeElem.Transformation) > 0 {
-                       err = 
errors.Convert(json.Unmarshal(scopeElem.Transformation, &transformationRules))
-                       if err != nil {
-                               return nil, err
-                       }
-               }
-               taskOptions := make(map[string]interface{})
-               err = errors.Convert(json.Unmarshal(scopeElem.Options, 
&taskOptions))
-               if err != nil {
-                       return nil, err
-               }
-               taskOptions["connectionId"] = connectionId
-               taskOptions["transformationRules"] = transformationRules
-               _, err := tasks.DecodeAndValidateTaskOptions(taskOptions)
-               if err != nil {
-                       return nil, err
-               }
-               // subtasks
-               subtasks, err := helper.MakePipelinePlanSubtasks(subtaskMetas, 
scopeElem.Entities)
-               if err != nil {
-                       return nil, err
-               }
-               plan[i] = plugin.PipelineStage{
-                       {
-                               Plugin:   "jira",
-                               Subtasks: subtasks,
-                               Options:  taskOptions,
-                       },
-               }
-       }
-       return plan, nil
-}
diff --git a/backend/plugins/jira/api/blueprint_v200.go 
b/backend/plugins/jira/api/blueprint_v200.go
index 7ae0af6fb..66434aade 100644
--- a/backend/plugins/jira/api/blueprint_v200.go
+++ b/backend/plugins/jira/api/blueprint_v200.go
@@ -21,6 +21,7 @@ import (
        "fmt"
        "time"
 
+       "github.com/apache/incubator-devlake/core/context"
        "github.com/apache/incubator-devlake/core/dal"
        "github.com/apache/incubator-devlake/core/errors"
        "github.com/apache/incubator-devlake/core/models/domainlayer"
@@ -34,11 +35,11 @@ import (
 
 func MakeDataSourcePipelinePlanV200(subtaskMetas []plugin.SubTaskMeta, 
connectionId uint64, bpScopes []*plugin.BlueprintScopeV200, syncPolicy 
*plugin.BlueprintSyncPolicy) (plugin.PipelinePlan, []plugin.Scope, 
errors.Error) {
        plan := make(plugin.PipelinePlan, len(bpScopes))
-       plan, err := makeDataSourcePipelinePlanV200(subtaskMetas, plan, 
bpScopes, connectionId, syncPolicy)
+       plan, err := makeDataSourcePipelinePlanV200(basicRes, subtaskMetas, 
plan, bpScopes, connectionId, syncPolicy)
        if err != nil {
                return nil, nil, err
        }
-       scopes, err := makeScopesV200(bpScopes, connectionId)
+       scopes, err := makeScopesV200(basicRes, bpScopes, connectionId)
        if err != nil {
                return nil, nil, err
        }
@@ -46,7 +47,23 @@ func MakeDataSourcePipelinePlanV200(subtaskMetas 
[]plugin.SubTaskMeta, connectio
        return plan, scopes, nil
 }
 
+func getScopeConfigByScopeId(basicRes context.BasicRes, scopeId string) 
(*models.JiraScopeConfig, errors.Error) {
+       db := basicRes.GetDal()
+       scopeConfig := &models.JiraScopeConfig{}
+       err := db.First(scopeConfig,
+               dal.Select("sc.*"),
+               dal.From("_tool_jira_scope_configs sc"),
+               dal.Join("LEFT JOIN _tool_jira_boards b ON (b.scope_config_id = 
sc.id)"),
+               dal.Where("b.board_id = ?", scopeId),
+       )
+       if err != nil {
+               return nil, err
+       }
+       return scopeConfig, nil
+}
+
 func makeDataSourcePipelinePlanV200(
+       basicRes context.BasicRes,
        subtaskMetas []plugin.SubTaskMeta,
        plan plugin.PipelinePlan,
        bpScopes []*plugin.BlueprintScopeV200,
@@ -66,7 +83,12 @@ func makeDataSourcePipelinePlanV200(
                        options["timeAfter"] = 
syncPolicy.TimeAfter.Format(time.RFC3339)
                }
 
-               subtasks, err := helper.MakePipelinePlanSubtasks(subtaskMetas, 
bpScope.Entities)
+               scopeConfig, err := getScopeConfigByScopeId(basicRes, 
bpScope.Id)
+               if err != nil {
+                       return nil, err
+               }
+
+               subtasks, err := helper.MakePipelinePlanSubtasks(subtaskMetas, 
scopeConfig.Entities)
                if err != nil {
                        return nil, err
                }
@@ -81,7 +103,11 @@ func makeDataSourcePipelinePlanV200(
        return plan, nil
 }
 
-func makeScopesV200(bpScopes []*plugin.BlueprintScopeV200, connectionId 
uint64) ([]plugin.Scope, errors.Error) {
+func makeScopesV200(
+       basicRes context.BasicRes,
+       bpScopes []*plugin.BlueprintScopeV200,
+       connectionId uint64,
+) ([]plugin.Scope, errors.Error) {
        scopes := make([]plugin.Scope, 0)
        for _, bpScope := range bpScopes {
                jiraBoard := &models.JiraBoard{}
@@ -92,8 +118,12 @@ func makeScopesV200(bpScopes []*plugin.BlueprintScopeV200, 
connectionId uint64)
                if err != nil {
                        return nil, errors.Default.Wrap(err, fmt.Sprintf("fail 
to find board %s", bpScope.Id))
                }
+               scopeConfig, err := getScopeConfigByScopeId(basicRes, 
bpScope.Id)
+               if err != nil {
+                       return nil, err
+               }
                // add board to scopes
-               if utils.StringsContains(bpScope.Entities, 
plugin.DOMAIN_TYPE_TICKET) {
+               if utils.StringsContains(scopeConfig.Entities, 
plugin.DOMAIN_TYPE_TICKET) {
                        domainBoard := &ticket.Board{
                                DomainEntity: domainlayer.DomainEntity{
                                        Id: 
didgen.NewDomainIdGenerator(&models.JiraBoard{}).Generate(jiraBoard.ConnectionId,
 jiraBoard.BoardId),
diff --git a/backend/plugins/jira/api/blueprint_v200_test.go 
b/backend/plugins/jira/api/blueprint_v200_test.go
index 8aaf0142a..94c554261 100644
--- a/backend/plugins/jira/api/blueprint_v200_test.go
+++ b/backend/plugins/jira/api/blueprint_v200_test.go
@@ -18,6 +18,9 @@ limitations under the License.
 package api
 
 import (
+       "testing"
+
+       "github.com/apache/incubator-devlake/core/models/common"
        "github.com/apache/incubator-devlake/core/models/domainlayer"
        "github.com/apache/incubator-devlake/core/models/domainlayer/ticket"
        "github.com/apache/incubator-devlake/core/plugin"
@@ -27,7 +30,6 @@ import (
        "github.com/apache/incubator-devlake/plugins/jira/models"
        "github.com/stretchr/testify/assert"
        "github.com/stretchr/testify/mock"
-       "testing"
 )
 
 func TestMakeDataSourcePipelinePlanV200(t *testing.T) {
@@ -36,17 +38,16 @@ func TestMakeDataSourcePipelinePlanV200(t *testing.T) {
        err := plugin.RegisterPlugin("jira", mockMeta)
        assert.Nil(t, err)
        bs := &plugin.BlueprintScopeV200{
-               Entities: []string{"TICKET"},
-               Id:       "10",
+               Id: "10",
        }
        syncPolicy := &plugin.BlueprintSyncPolicy{}
        bpScopes := make([]*plugin.BlueprintScopeV200, 0)
        bpScopes = append(bpScopes, bs)
        plan := make(plugin.PipelinePlan, len(bpScopes))
-       plan, err = makeDataSourcePipelinePlanV200(nil, plan, bpScopes, 
uint64(1), syncPolicy)
-       assert.Nil(t, err)
        basicRes = NewMockBasicRes()
-       scopes, err := makeScopesV200(bpScopes, uint64(1))
+       plan, err = makeDataSourcePipelinePlanV200(basicRes, nil, plan, 
bpScopes, uint64(1), syncPolicy)
+       assert.Nil(t, err)
+       scopes, err := makeScopesV200(basicRes, bpScopes, uint64(1))
        assert.Nil(t, err)
 
        expectPlan := plugin.PipelinePlan{
@@ -82,14 +83,23 @@ func NewMockBasicRes() *mockcontext.BasicRes {
                BoardId:      10,
                Name:         "a",
        }
+       scopeConfig := &models.JiraScopeConfig{
+               ScopeConfig: common.ScopeConfig{
+                       Entities: []string{plugin.DOMAIN_TYPE_TICKET},
+               },
+       }
 
        mockRes := new(mockcontext.BasicRes)
        mockDal := new(mockdal.Dal)
 
-       mockDal.On("First", mock.Anything, mock.Anything).Run(func(args 
mock.Arguments) {
+       mockDal.On("First", mock.AnythingOfType("*models.JiraScopeConfig"), 
mock.Anything).Run(func(args mock.Arguments) {
+               dst := args.Get(0).(*models.JiraScopeConfig)
+               *dst = *scopeConfig
+       }).Return(nil)
+       mockDal.On("First", mock.AnythingOfType("*models.JiraBoard"), 
mock.Anything).Run(func(args mock.Arguments) {
                dst := args.Get(0).(*models.JiraBoard)
                *dst = *jiraBoard
-       }).Return(nil).Once()
+       }).Return(nil)
 
        mockRes.On("GetDal").Return(mockDal)
        mockRes.On("GetConfig", mock.Anything).Return("")
diff --git a/backend/plugins/jira/api/init.go b/backend/plugins/jira/api/init.go
index 9944236e0..b38d8218c 100644
--- a/backend/plugins/jira/api/init.go
+++ b/backend/plugins/jira/api/init.go
@@ -26,9 +26,9 @@ import (
 
 var vld *validator.Validate
 var connectionHelper *api.ConnectionApiHelper
-var scopeHelper *api.ScopeApiHelper[models.JiraConnection, models.JiraBoard, 
models.JiraTransformationRule]
+var scopeHelper *api.ScopeApiHelper[models.JiraConnection, models.JiraBoard, 
models.JiraScopeConfig]
 var basicRes context.BasicRes
-var trHelper *api.TransformationRuleHelper[models.JiraTransformationRule]
+var scHelper *api.ScopeConfigHelper[models.JiraScopeConfig]
 
 func Init(br context.BasicRes) {
        basicRes = br
@@ -41,16 +41,16 @@ func Init(br context.BasicRes) {
                ScopeIdFieldName:  "BoardID",
                ScopeIdColumnName: "board_id",
        }
-       scopeHelper = api.NewScopeHelper[models.JiraConnection, 
models.JiraBoard, models.JiraTransformationRule](
+       scopeHelper = api.NewScopeHelper[models.JiraConnection, 
models.JiraBoard, models.JiraScopeConfig](
                basicRes,
                vld,
                connectionHelper,
-               api.NewScopeDatabaseHelperImpl[models.JiraConnection, 
models.JiraBoard, models.JiraTransformationRule](
+               api.NewScopeDatabaseHelperImpl[models.JiraConnection, 
models.JiraBoard, models.JiraScopeConfig](
                        basicRes, connectionHelper, params),
                params,
                nil,
        )
-       trHelper = 
api.NewTransformationRuleHelper[models.JiraTransformationRule](
+       scHelper = api.NewScopeConfigHelper[models.JiraScopeConfig](
                basicRes,
                vld,
        )
diff --git a/backend/plugins/jira/api/scope.go 
b/backend/plugins/jira/api/scope.go
index 2743639eb..0a8edea37 100644
--- a/backend/plugins/jira/api/scope.go
+++ b/backend/plugins/jira/api/scope.go
@@ -33,7 +33,7 @@ import (
 
 type ScopeRes struct {
        models.JiraBoard
-       TransformationRuleName string `json:"transformationRuleName,omitempty"`
+       ScopeConfigName string `json:"scopeConfigName,omitempty"`
 }
 
 type ScopeReq api.ScopeReq[models.JiraBoard]
diff --git a/backend/plugins/jira/api/transformation_rule.go 
b/backend/plugins/jira/api/scope_config.go
similarity index 55%
rename from backend/plugins/jira/api/transformation_rule.go
rename to backend/plugins/jira/api/scope_config.go
index cf3899edc..ccc9e125e 100644
--- a/backend/plugins/jira/api/transformation_rule.go
+++ b/backend/plugins/jira/api/scope_config.go
@@ -30,63 +30,63 @@ import (
        "github.com/mitchellh/mapstructure"
 )
 
-// CreateTransformationRule create transformation rule for Jira
-// @Summary create transformation rule for Jira
-// @Description create transformation rule for Jira
+// CreateScopeConfig create scope config for Jira
+// @Summary create scope config for Jira
+// @Description create scope config for Jira
 // @Tags plugins/jira
 // @Accept application/json
 // @Param connectionId path int true "connectionId"
-// @Param transformationRule body tasks.JiraTransformationRule true 
"transformation rule"
-// @Success 200  {object} tasks.JiraTransformationRule
+// @Param scopeConfig body tasks.JiraScopeConfig true "scope config"
+// @Success 200  {object} tasks.JiraScopeConfig
 // @Failure 400  {object} shared.ApiBody "Bad Request"
 // @Failure 500  {object} shared.ApiBody "Internal Error"
-// @Router /plugins/jira/connections/{connectionId}/transformation_rules [POST]
-func CreateTransformationRule(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, errors.Error) {
-       rule, err := makeDbTransformationRuleFromInput(input)
+// @Router /plugins/jira/connections/{connectionId}/scope_configs [POST]
+func CreateScopeConfig(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, errors.Error) {
+       rule, err := makeDbScopeConfigFromInput(input)
        if err != nil {
-               return nil, errors.BadInput.Wrap(err, "error in 
makeJiraTransformationRule")
+               return nil, errors.BadInput.Wrap(err, "error in 
makeJiraScopeConfig")
        }
        newRule := map[string]interface{}{}
        err = errors.Convert(mapstructure.Decode(rule, &newRule))
        if err != nil {
-               return nil, errors.BadInput.Wrap(err, "error in 
makeJiraTransformationRule")
+               return nil, errors.BadInput.Wrap(err, "error in 
makeJiraScopeConfig")
        }
        input.Body = newRule
-       return trHelper.Create(input)
+       return scHelper.Create(input)
 }
 
-// UpdateTransformationRule update transformation rule for Jira
-// @Summary update transformation rule for Jira
-// @Description update transformation rule for Jira
+// UpdateScopeConfig update scope config for Jira
+// @Summary update scope config for Jira
+// @Description update scope config for Jira
 // @Tags plugins/jira
 // @Accept application/json
 // @Param id path int true "id"
 // @Param connectionId path int true "connectionId"
-// @Param transformationRule body tasks.JiraTransformationRule true 
"transformation rule"
-// @Success 200  {object} tasks.JiraTransformationRule
+// @Param scopeConfig body tasks.JiraScopeConfig true "scope config"
+// @Success 200  {object} tasks.JiraScopeConfig
 // @Failure 400  {object} shared.ApiBody "Bad Request"
 // @Failure 500  {object} shared.ApiBody "Internal Error"
-// @Router /plugins/jira/connections/{connectionId}/transformation_rules/{id} 
[PATCH]
-func UpdateTransformationRule(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, errors.Error) {
+// @Router /plugins/jira/connections/{connectionId}/scope_configs/{id} [PATCH]
+func UpdateScopeConfig(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, errors.Error) {
        connectionId, e := strconv.ParseUint(input.Params["connectionId"], 10, 
64)
        if e != nil || connectionId == 0 {
                return nil, errors.Default.Wrap(e, "the connection ID should be 
an non-zero integer")
        }
-       transformationRuleId, e := strconv.ParseUint(input.Params["id"], 10, 64)
+       scopeConfigId, e := strconv.ParseUint(input.Params["id"], 10, 64)
        if e != nil {
-               return nil, errors.Default.Wrap(e, "the transformation rule ID 
should be an integer")
+               return nil, errors.Default.Wrap(e, "the scope config ID should 
be an integer")
        }
-       var req tasks.JiraTransformationRule
+       var req tasks.JiraScopeConfig
        err := api.Decode(input.Body, &req, vld)
        if err != nil {
                return nil, err
        }
-       var oldDB models.JiraTransformationRule
-       err = basicRes.GetDal().First(&oldDB, dal.Where("id = ?", 
transformationRuleId))
+       var oldDB models.JiraScopeConfig
+       err = basicRes.GetDal().First(&oldDB, dal.Where("id = ?", 
scopeConfigId))
        if err != nil {
-               return nil, errors.Default.Wrap(err, "error on getting 
TransformationRule")
+               return nil, errors.Default.Wrap(err, "error on getting 
ScopeConfig")
        }
-       oldTr, err := tasks.MakeTransformationRules(oldDB)
+       oldTr, err := tasks.MakeScopeConfig(oldDB)
        if err != nil {
                return nil, err
        }
@@ -99,7 +99,7 @@ func UpdateTransformationRule(input *plugin.ApiResourceInput) 
(*plugin.ApiResour
        if err != nil {
                return nil, err
        }
-       newDB.ID = transformationRuleId
+       newDB.ID = scopeConfigId
        newDB.ConnectionId = connectionId
        newDB.CreatedAt = oldDB.CreatedAt
        err = basicRes.GetDal().Update(newDB)
@@ -109,12 +109,12 @@ func UpdateTransformationRule(input 
*plugin.ApiResourceInput) (*plugin.ApiResour
        return &plugin.ApiResourceOutput{Body: newDB, Status: http.StatusOK}, 
err
 }
 
-func makeDbTransformationRuleFromInput(input *plugin.ApiResourceInput) 
(*models.JiraTransformationRule, errors.Error) {
+func makeDbScopeConfigFromInput(input *plugin.ApiResourceInput) 
(*models.JiraScopeConfig, errors.Error) {
        connectionId, e := strconv.ParseUint(input.Params["connectionId"], 10, 
64)
        if e != nil || connectionId == 0 {
                return nil, errors.Default.Wrap(e, "the connection ID should be 
an non-zero integer")
        }
-       var req tasks.JiraTransformationRule
+       var req tasks.JiraScopeConfig
        err := api.Decode(input.Body, &req, vld)
        if err != nil {
                return nil, err
@@ -123,31 +123,31 @@ func makeDbTransformationRuleFromInput(input 
*plugin.ApiResourceInput) (*models.
        return req.ToDb()
 }
 
-// GetTransformationRule return one transformation rule
-// @Summary return one transformation rule
-// @Description return one transformation rule
+// GetScopeConfig return one scope config
+// @Summary return one scope config
+// @Description return one scope config
 // @Tags plugins/jira
 // @Param id path int true "id"
 // @Param connectionId path int true "connectionId"
-// @Success 200  {object} tasks.JiraTransformationRule
+// @Success 200  {object} tasks.JiraScopeConfig
 // @Failure 400  {object} shared.ApiBody "Bad Request"
 // @Failure 500  {object} shared.ApiBody "Internal Error"
-// @Router /plugins/jira/connections/{connectionId}/transformation_rules/{id} 
[GET]
-func GetTransformationRule(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, errors.Error) {
-       return trHelper.Get(input)
+// @Router /plugins/jira/connections/{connectionId}/scope_configs/{id} [GET]
+func GetScopeConfig(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, errors.Error) {
+       return scHelper.Get(input)
 }
 
-// GetTransformationRuleList return all transformation rules
-// @Summary return all transformation rules
-// @Description return all transformation rules
+// GetScopeConfigList return all scope configs
+// @Summary return all scope configs
+// @Description return all scope configs
 // @Tags plugins/jira
 // @Param connectionId path int true "connectionId"
 // @Param pageSize query int false "page size, default 50"
 // @Param page query int false "page size, default 1"
-// @Success 200  {object} []tasks.JiraTransformationRule
+// @Success 200  {object} []tasks.JiraScopeConfig
 // @Failure 400  {object} shared.ApiBody "Bad Request"
 // @Failure 500  {object} shared.ApiBody "Internal Error"
-// @Router /plugins/jira/connections/{connectionId}/transformation_rules [GET]
-func GetTransformationRuleList(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, errors.Error) {
-       return trHelper.List(input)
+// @Router /plugins/jira/connections/{connectionId}/scope_configs [GET]
+func GetScopeConfigList(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, errors.Error) {
+       return scHelper.List(input)
 }
diff --git a/backend/plugins/jira/api/swagger.go 
b/backend/plugins/jira/api/swagger.go
index 6e8965d7c..fd1c73639 100644
--- a/backend/plugins/jira/api/swagger.go
+++ b/backend/plugins/jira/api/swagger.go
@@ -21,44 +21,12 @@ import (
        "github.com/apache/incubator-devlake/plugins/jira/tasks"
 )
 
-// @Summary blueprints setting for jira
-// @Description blueprint setting for jira
-// @Tags plugins/jira
-// @Accept application/json
-// @Param blueprint-setting body JiraBlueprintSetting true "json"
-// @Router /blueprints/jira/blueprint-setting [post]
-func _() {}
+type JiraTaskOptions tasks.JiraOptions
 
-type JiraBlueprintSetting []struct {
-       Version     string `json:"version"`
-       Connections []struct {
-               Plugin       string `json:"plugin"`
-               ConnectionID int    `json:"connectionId"`
-               Scope        []struct {
-                       Transformation tasks.JiraTransformationRule 
`json:"transformation"`
-                       Options        struct {
-                               BoardId uint64 `json:"boardId"`
-                               Since   string `json:"since"`
-                       } `json:"options"`
-                       Entities []string `json:"entities"`
-               } `json:"scopes"`
-       } `json:"connections"`
-}
-
-// @Summary pipelines plan for jira
-// @Description pipelines plan for jira
+// @Summary jira task options for pipelines
+// @Description This is a dummy API to demonstrate the available task options 
for jira pipelines
 // @Tags plugins/jira
 // @Accept application/json
-// @Param pipeline-plan body JiraPipelinePlan true "json"
-// @Router /pipelines/jira/pipeline-plan [post]
+// @Param pipeline body JiraTaskOptions true "json"
+// @Router /pipelines/jira/pipeline-task [post]
 func _() {}
-
-type JiraPipelinePlan [][]struct {
-       Plugin   string   `json:"plugin"`
-       Subtasks []string `json:"subtasks"`
-       Options  struct {
-               BoardID             int                          
`json:"boardId"`
-               ConnectionID        int                          
`json:"connectionId"`
-               TransformationRules tasks.JiraTransformationRule 
`json:"transformationRules"`
-       } `json:"options"`
-}
diff --git a/backend/plugins/jira/e2e/epic_test.go 
b/backend/plugins/jira/e2e/epic_test.go
index 157831e33..f9c631ec1 100644
--- a/backend/plugins/jira/e2e/epic_test.go
+++ b/backend/plugins/jira/e2e/epic_test.go
@@ -18,12 +18,13 @@ limitations under the License.
 package e2e
 
 import (
+       "testing"
+
        "github.com/apache/incubator-devlake/core/models/common"
        "github.com/apache/incubator-devlake/helpers/e2ehelper"
        "github.com/apache/incubator-devlake/plugins/jira/impl"
        "github.com/apache/incubator-devlake/plugins/jira/models"
        "github.com/apache/incubator-devlake/plugins/jira/tasks"
-       "testing"
 
        "github.com/stretchr/testify/require"
 )
@@ -33,9 +34,9 @@ func TestEpicDataflow(t *testing.T) {
        dataflowTester := e2ehelper.NewDataFlowTester(t, "jira", plugin)
        taskData := &tasks.JiraTaskData{
                Options: &tasks.JiraOptions{
-                       ConnectionId:        1,
-                       BoardId:             93,
-                       TransformationRules: 
&tasks.JiraTransformationRule{StoryPointField: "customfield_10024"},
+                       ConnectionId: 1,
+                       BoardId:      93,
+                       ScopeConfig:  &tasks.JiraScopeConfig{StoryPointField: 
"customfield_10024"},
                },
        }
 
diff --git a/backend/plugins/jira/e2e/issue_repo_commit_test.go 
b/backend/plugins/jira/e2e/issue_repo_commit_test.go
index 3535aeaec..4a5f3e0df 100644
--- a/backend/plugins/jira/e2e/issue_repo_commit_test.go
+++ b/backend/plugins/jira/e2e/issue_repo_commit_test.go
@@ -18,12 +18,13 @@ limitations under the License.
 package e2e
 
 import (
+       "testing"
+
        
"github.com/apache/incubator-devlake/core/models/domainlayer/crossdomain"
        "github.com/apache/incubator-devlake/helpers/e2ehelper"
        "github.com/apache/incubator-devlake/plugins/jira/impl"
        "github.com/apache/incubator-devlake/plugins/jira/models"
        "github.com/apache/incubator-devlake/plugins/jira/tasks"
-       "testing"
 )
 
 func TestConvertIssueRepoCommitsDataFlow(t *testing.T) {
@@ -34,7 +35,7 @@ func TestConvertIssueRepoCommitsDataFlow(t *testing.T) {
                Options: &tasks.JiraOptions{
                        ConnectionId: 2,
                        BoardId:      8,
-                       TransformationRules: &tasks.JiraTransformationRule{
+                       ScopeConfig: &tasks.JiraScopeConfig{
                                RemotelinkCommitShaPattern: `.*/commit/(.*)`,
                                RemotelinkRepoPattern: []string{
                                        
`https://bitbucket.org/(?P<namespace>[^/]+)/(?P<repo_name>[^/]+)/commits/(?P<commit_sha>\w{40})`,
diff --git a/backend/plugins/jira/e2e/issue_test.go 
b/backend/plugins/jira/e2e/issue_test.go
index 8f393484e..dec15eecb 100644
--- a/backend/plugins/jira/e2e/issue_test.go
+++ b/backend/plugins/jira/e2e/issue_test.go
@@ -35,7 +35,7 @@ func TestIssueDataFlow(t *testing.T) {
                Options: &tasks.JiraOptions{
                        ConnectionId: 2,
                        BoardId:      8,
-                       TransformationRules: &tasks.JiraTransformationRule{
+                       ScopeConfig: &tasks.JiraScopeConfig{
                                StoryPointField: "customfield_10024",
                                TypeMappings: map[string]tasks.TypeMapping{
                                        "子任务": {
diff --git a/backend/plugins/jira/e2e/remotelink_test.go 
b/backend/plugins/jira/e2e/remotelink_test.go
index aefe374c2..5192e4b97 100644
--- a/backend/plugins/jira/e2e/remotelink_test.go
+++ b/backend/plugins/jira/e2e/remotelink_test.go
@@ -18,11 +18,12 @@ limitations under the License.
 package e2e
 
 import (
+       "testing"
+
        "github.com/apache/incubator-devlake/helpers/e2ehelper"
        "github.com/apache/incubator-devlake/plugins/jira/impl"
        "github.com/apache/incubator-devlake/plugins/jira/models"
        "github.com/apache/incubator-devlake/plugins/jira/tasks"
-       "testing"
 )
 
 func TestRemotelinkDataFlow(t *testing.T) {
@@ -33,7 +34,7 @@ func TestRemotelinkDataFlow(t *testing.T) {
                Options: &tasks.JiraOptions{
                        ConnectionId: 2,
                        BoardId:      8,
-                       TransformationRules: &tasks.JiraTransformationRule{
+                       ScopeConfig: &tasks.JiraScopeConfig{
                                RemotelinkCommitShaPattern: ".*/commit/(.*)",
                                RemotelinkRepoPattern:      
[]string{`https://example.com/(?P<namespace>\S+)/(?P<repo_name>\S+)/-/commits/(?P<commit_sha>\w{40})`},
                        },
diff --git a/backend/plugins/jira/impl/impl.go 
b/backend/plugins/jira/impl/impl.go
index c1263bef9..b345f01fb 100644
--- a/backend/plugins/jira/impl/impl.go
+++ b/backend/plugins/jira/impl/impl.go
@@ -40,7 +40,6 @@ var _ interface {
        plugin.PluginTask
        plugin.PluginModel
        plugin.PluginMigration
-       plugin.PluginBlueprintV100
        plugin.DataSourcePluginBlueprintV200
        plugin.CloseablePluginTask
        plugin.PluginSource
@@ -57,8 +56,8 @@ func (p Jira) Scope() interface{} {
        return &models.JiraBoard{}
 }
 
-func (p Jira) TransformationRule() interface{} {
-       return &models.JiraTransformationRule{}
+func (p Jira) ScopeConfig() interface{} {
+       return &models.JiraScopeConfig{}
 }
 
 func (p *Jira) Init(basicRes context.BasicRes) errors.Error {
@@ -207,19 +206,19 @@ func (p Jira) PrepareTaskData(taskCtx plugin.TaskContext, 
options map[string]int
                        return nil, errors.Default.Wrap(err, fmt.Sprintf("fail 
to find board%s", op.ScopeId))
                }
                op.BoardId = jiraBoard.BoardId
-               if op.TransformationRuleId == 0 {
-                       op.TransformationRuleId = jiraBoard.TransformationRuleId
+               if op.ScopeConfigId == 0 {
+                       op.ScopeConfigId = jiraBoard.ScopeConfigId
                }
        }
-       if op.TransformationRules == nil && op.TransformationRuleId != 0 {
-               var transformationRule models.JiraTransformationRule
-               err = taskCtx.GetDal().First(&transformationRule, dal.Where("id 
= ?", op.TransformationRuleId))
+       if op.ScopeConfig == nil && op.ScopeConfigId != 0 {
+               var scopeConfig models.JiraScopeConfig
+               err = taskCtx.GetDal().First(&scopeConfig, dal.Where("id = ?", 
op.ScopeConfigId))
                if err != nil && db.IsErrorNotFound(err) {
-                       return nil, errors.BadInput.Wrap(err, "fail to get 
transformationRule")
+                       return nil, errors.BadInput.Wrap(err, "fail to get 
scopeConfig")
                }
-               op.TransformationRules, err = 
tasks.MakeTransformationRules(transformationRule)
+               op.ScopeConfig, err = tasks.MakeScopeConfig(scopeConfig)
                if err != nil {
-                       return nil, errors.BadInput.Wrap(err, "fail to make 
transformationRule")
+                       return nil, errors.BadInput.Wrap(err, "fail to make 
scopeConfig")
                }
        }
 
@@ -249,10 +248,6 @@ func (p Jira) PrepareTaskData(taskCtx plugin.TaskContext, 
options map[string]int
        return taskData, nil
 }
 
-func (p Jira) MakePipelinePlan(connectionId uint64, scope 
[]*plugin.BlueprintScopeV100) (plugin.PipelinePlan, errors.Error) {
-       return api.MakePipelinePlanV100(p.SubTaskMetas(), connectionId, scope)
-}
-
 func (p Jira) MakeDataSourcePipelinePlanV200(connectionId uint64, scopes 
[]*plugin.BlueprintScopeV200, syncPolicy plugin.BlueprintSyncPolicy) (pp 
plugin.PipelinePlan, sc []plugin.Scope, err errors.Error) {
        return api.MakeDataSourcePipelinePlanV200(p.SubTaskMetas(), 
connectionId, scopes, &syncPolicy)
 }
@@ -296,13 +291,13 @@ func (p Jira) ApiResources() 
map[string]map[string]plugin.ApiResourceHandler {
                        "GET": api.GetScopeList,
                        "PUT": api.PutScope,
                },
-               "connections/:connectionId/transformation_rules": {
-                       "POST": api.CreateTransformationRule,
-                       "GET":  api.GetTransformationRuleList,
+               "connections/:connectionId/scope_configs": {
+                       "POST": api.CreateScopeConfig,
+                       "GET":  api.GetScopeConfigList,
                },
-               "connections/:connectionId/transformation_rules/:id": {
-                       "PATCH": api.UpdateTransformationRule,
-                       "GET":   api.GetTransformationRule,
+               "connections/:connectionId/scope_configs/:id": {
+                       "PATCH": api.UpdateScopeConfig,
+                       "GET":   api.GetScopeConfig,
                },
        }
 }
diff --git a/backend/plugins/jira/models/board.go 
b/backend/plugins/jira/models/board.go
index 82a737a64..d5e33ebe4 100644
--- a/backend/plugins/jira/models/board.go
+++ b/backend/plugins/jira/models/board.go
@@ -25,7 +25,7 @@ type JiraBoard struct {
        common.NoPKModel     `json:"-" mapstructure:"-"`
        ConnectionId         uint64 `json:"connectionId" 
mapstructure:"connectionId" validate:"required" gorm:"primaryKey"`
        BoardId              uint64 `json:"boardId" mapstructure:"boardId" 
validate:"required" gorm:"primaryKey"`
-       TransformationRuleId uint64 `json:"transformationRuleId,omitempty" 
mapstructure:"transformationRuleId"`
+       ScopeConfigId uint64 `json:"scopeConfigId,omitempty" 
mapstructure:"scopeConfigId"`
        ProjectId            uint   `json:"projectId" mapstructure:"projectId"`
        Name                 string `json:"name" mapstructure:"name" 
gorm:"type:varchar(255)"`
        Self                 string `json:"self" mapstructure:"self" 
gorm:"type:varchar(255)"`
diff --git 
a/backend/plugins/jira/models/migrationscripts/20230322_add_connection_id_to_transformation_rules.go
 
b/backend/plugins/jira/models/migrationscripts/20230322_add_connection_id_to_transformation_rules.go
index 7a6af67a5..101dafc3a 100644
--- 
a/backend/plugins/jira/models/migrationscripts/20230322_add_connection_id_to_transformation_rules.go
+++ 
b/backend/plugins/jira/models/migrationscripts/20230322_add_connection_id_to_transformation_rules.go
@@ -22,25 +22,34 @@ import (
        "github.com/apache/incubator-devlake/core/dal"
        "github.com/apache/incubator-devlake/core/errors"
        "github.com/apache/incubator-devlake/helpers/migrationhelper"
-       "github.com/apache/incubator-devlake/plugins/jira/models"
 )
 
 type addConnectionIdToTransformationRule struct{}
 
-type transformationRule20220322 struct {
+type board20230322 struct {
+       ConnectionId         uint64 `json:"connectionId" 
mapstructure:"connectionId" validate:"required" gorm:"primaryKey"`
+       BoardId              uint64 `json:"boardId" mapstructure:"boardId" 
validate:"required" gorm:"primaryKey"`
+       TransformationRuleId uint64 `json:"scopeConfigId,omitempty" 
mapstructure:"scopeConfigId"`
+}
+
+func (board20230322) TableName() string {
+       return "_tool_jira_boards"
+}
+
+type transformationRule20230322 struct {
        ConnectionId uint64
 }
 
-func (transformationRule20220322) TableName() string {
+func (transformationRule20230322) TableName() string {
        return "_tool_jira_transformation_rules"
 }
 
 func (u *addConnectionIdToTransformationRule) Up(baseRes context.BasicRes) 
errors.Error {
-       err := migrationhelper.AutoMigrateTables(baseRes, 
&transformationRule20220322{})
+       err := migrationhelper.AutoMigrateTables(baseRes, 
&transformationRule20230322{})
        if err != nil {
                return err
        }
-       var scopes []models.JiraBoard
+       var scopes []board20230322
        err = baseRes.GetDal().All(&scopes)
        if err != nil {
                return err
@@ -55,14 +64,14 @@ func (u *addConnectionIdToTransformationRule) Up(baseRes 
context.BasicRes) error
        // set connection_id for rules
        for trId, cId := range idMap {
                err = baseRes.GetDal().UpdateColumn(
-                       &models.JiraTransformationRule{}, "connection_id", cId,
+                       &board20230322{}, "connection_id", cId,
                        dal.Where("id = ?", trId))
                if err != nil {
                        return err
                }
        }
        // delete all rules that are not referenced.
-       return baseRes.GetDal().Delete(&models.JiraTransformationRule{}, 
dal.Where("connection_id IS NULL OR connection_id = 0"))
+       return baseRes.GetDal().Delete(&board20230322{}, 
dal.Where("connection_id IS NULL OR connection_id = 0"))
 }
 
 func (*addConnectionIdToTransformationRule) Version() uint64 {
diff --git 
a/backend/plugins/jira/models/migrationscripts/20230530_scope_config.go 
b/backend/plugins/jira/models/migrationscripts/20230530_scope_config.go
new file mode 100644
index 000000000..c6aec38cc
--- /dev/null
+++ b/backend/plugins/jira/models/migrationscripts/20230530_scope_config.go
@@ -0,0 +1,56 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+       "github.com/apache/incubator-devlake/core/context"
+       "github.com/apache/incubator-devlake/core/errors"
+       "github.com/apache/incubator-devlake/helpers/migrationhelper"
+)
+
+type renameTr2ScopeConfig struct {
+}
+
+type scopeConfig20230530 struct {
+       Entities []string `gorm:"type:json" json:"entities"`
+}
+
+func (scopeConfig20230530) TableName() string {
+       return "_tool_jira_scope_configs"
+}
+
+func (u *renameTr2ScopeConfig) Up(baseRes context.BasicRes) errors.Error {
+       db := baseRes.GetDal()
+       err := db.RenameColumn("_tool_jira_boards", "transformation_rule_id", 
"scope_config_id")
+       if err != nil {
+               return err
+       }
+       err = db.RenameTable("_tool_jira_transformation_rules", 
"_tool_jira_scope_configs")
+       if err != nil {
+               return err
+       }
+       return migrationhelper.AutoMigrateTables(baseRes, 
&scopeConfig20230530{})
+}
+
+func (*renameTr2ScopeConfig) Version() uint64 {
+       return 20230530150031
+}
+
+func (*renameTr2ScopeConfig) Name() string {
+       return "rename transformation rule to scope config for jira"
+}
diff --git a/backend/plugins/jira/models/migrationscripts/register.go 
b/backend/plugins/jira/models/migrationscripts/register.go
index 1ff183456..bb86ff68f 100644
--- a/backend/plugins/jira/models/migrationscripts/register.go
+++ b/backend/plugins/jira/models/migrationscripts/register.go
@@ -37,5 +37,6 @@ func All() []plugin.MigrationScript {
                new(addChangeTotal20230412),
                new(expandRemotelinkSelfUrl),
                new(addDescAndComments),
+               new(renameTr2ScopeConfig),
        }
 }
diff --git a/backend/plugins/jira/models/transformation_rules.go 
b/backend/plugins/jira/models/scope_config.go
similarity index 90%
rename from backend/plugins/jira/models/transformation_rules.go
rename to backend/plugins/jira/models/scope_config.go
index 58d104555..f73fb1edc 100644
--- a/backend/plugins/jira/models/transformation_rules.go
+++ b/backend/plugins/jira/models/scope_config.go
@@ -25,8 +25,8 @@ import (
        "github.com/apache/incubator-devlake/core/models/common"
 )
 
-type JiraTransformationRule struct {
-       common.Model               `mapstructure:"-"`
+type JiraScopeConfig struct {
+       common.ScopeConfig         `mapstructure:",squash" json:",inline" 
gorm:"embedded"`
        ConnectionId               uint64          `mapstructure:"connectionId" 
json:"connectionId"`
        Name                       string          `mapstructure:"name" 
json:"name" gorm:"type:varchar(255);index:idx_name_jira,unique" 
validate:"required"`
        EpicKeyField               string          
`mapstructure:"epicKeyField,omitempty" json:"epicKeyField" 
gorm:"type:varchar(255)"`
@@ -36,11 +36,11 @@ type JiraTransformationRule struct {
        TypeMappings               json.RawMessage 
`mapstructure:"typeMappings,omitempty" json:"typeMappings"`
 }
 
-func (r JiraTransformationRule) TableName() string {
-       return "_tool_jira_transformation_rules"
+func (r JiraScopeConfig) TableName() string {
+       return "_tool_jira_scope_configs"
 }
 
-func (r JiraTransformationRule) VerifyRegexp() errors.Error {
+func (r JiraScopeConfig) VerifyRegexp() errors.Error {
        var err error
        if r.RemotelinkCommitShaPattern != "" {
                _, err = regexp.Compile(r.RemotelinkCommitShaPattern)
diff --git a/backend/plugins/jira/tasks/issue_extractor.go 
b/backend/plugins/jira/tasks/issue_extractor.go
index d4e99bed4..355086979 100644
--- a/backend/plugins/jira/tasks/issue_extractor.go
+++ b/backend/plugins/jira/tasks/issue_extractor.go
@@ -113,8 +113,8 @@ func extractIssues(data *JiraTaskData, mappings 
*typeMappings, row *api.RawData)
        if issue.ResolutionDate != nil {
                issue.LeadTimeMinutes = 
uint(issue.ResolutionDate.Unix()-issue.Created.Unix()) / 60
        }
-       if data.Options.TransformationRules != nil && 
data.Options.TransformationRules.StoryPointField != "" {
-               unknownStoryPoint := 
apiIssue.Fields.AllFields[data.Options.TransformationRules.StoryPointField]
+       if data.Options.ScopeConfig != nil && 
data.Options.ScopeConfig.StoryPointField != "" {
+               unknownStoryPoint := 
apiIssue.Fields.AllFields[data.Options.ScopeConfig.StoryPointField]
                switch sp := unknownStoryPoint.(type) {
                case string:
                        // string, try to parse
@@ -196,8 +196,8 @@ func getTypeMappings(data *JiraTaskData, db dal.Dal) 
(*typeMappings, errors.Erro
        }
        stdTypeMappings := make(map[string]string)
        standardStatusMappings := make(map[string]StatusMappings)
-       if data.Options.TransformationRules != nil {
-               for userType, stdType := range 
data.Options.TransformationRules.TypeMappings {
+       if data.Options.ScopeConfig != nil {
+               for userType, stdType := range 
data.Options.ScopeConfig.TypeMappings {
                        stdTypeMappings[userType] = 
strings.ToUpper(stdType.StandardType)
                        standardStatusMappings[userType] = 
stdType.StatusMappings
                }
diff --git a/backend/plugins/jira/tasks/issue_repo_commit_convertor.go 
b/backend/plugins/jira/tasks/issue_repo_commit_convertor.go
index aec1a0e00..061987cd7 100644
--- a/backend/plugins/jira/tasks/issue_repo_commit_convertor.go
+++ b/backend/plugins/jira/tasks/issue_repo_commit_convertor.go
@@ -54,8 +54,8 @@ func ConvertIssueRepoCommits(taskCtx plugin.SubTaskContext) 
errors.Error {
                return errors.Default.Wrap(err, "regexp Compile 
commitRepoUrlPattern failed")
        }
        var commitRepoUrlRegexps []*regexp.Regexp
-       if tr := data.Options.TransformationRules; tr != nil {
-               for _, s := range tr.RemotelinkRepoPattern {
+       if sc := data.Options.ScopeConfig; sc != nil {
+               for _, s := range sc.RemotelinkRepoPattern {
                        pattern, e := regexp.Compile(s)
                        if e != nil {
                                return errors.Convert(e)
diff --git a/backend/plugins/jira/tasks/remotelink_extractor.go 
b/backend/plugins/jira/tasks/remotelink_extractor.go
index d8bd6a029..f290a8765 100644
--- a/backend/plugins/jira/tasks/remotelink_extractor.go
+++ b/backend/plugins/jira/tasks/remotelink_extractor.go
@@ -19,12 +19,13 @@ package tasks
 
 import (
        "encoding/json"
+       "regexp"
+
        "github.com/apache/incubator-devlake/core/errors"
        "github.com/apache/incubator-devlake/core/plugin"
        "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
        "github.com/apache/incubator-devlake/plugins/jira/models"
        "github.com/apache/incubator-devlake/plugins/jira/tasks/apiv2models"
-       "regexp"
 )
 
 var ExtractRemotelinksMeta = plugin.SubTaskMeta{
@@ -44,16 +45,16 @@ func ExtractRemotelinks(taskCtx plugin.SubTaskContext) 
errors.Error {
 
        var err errors.Error
        var commitShaRegex *regexp.Regexp
-       if data.Options.TransformationRules != nil && 
data.Options.TransformationRules.RemotelinkCommitShaPattern != "" {
-               pattern := 
data.Options.TransformationRules.RemotelinkCommitShaPattern
+       if data.Options.ScopeConfig != nil && 
data.Options.ScopeConfig.RemotelinkCommitShaPattern != "" {
+               pattern := data.Options.ScopeConfig.RemotelinkCommitShaPattern
                commitShaRegex, err = errors.Convert01(regexp.Compile(pattern))
                if err != nil {
                        return errors.Default.Wrap(err, "regexp Compile pattern 
failed")
                }
        }
        var commitRepoUrlRegexps []*regexp.Regexp
-       if tr := data.Options.TransformationRules; tr != nil {
-               for _, s := range tr.RemotelinkRepoPattern {
+       if sc := data.Options.ScopeConfig; sc != nil {
+               for _, s := range sc.RemotelinkRepoPattern {
                        pattern, e := regexp.Compile(s)
                        if e != nil {
                                return errors.Convert(e)
diff --git a/backend/plugins/jira/tasks/task_data.go 
b/backend/plugins/jira/tasks/task_data.go
index 9ff425c80..c0488a6a7 100644
--- a/backend/plugins/jira/tasks/task_data.go
+++ b/backend/plugins/jira/tasks/task_data.go
@@ -40,7 +40,8 @@ type TypeMapping struct {
 
 type TypeMappings map[string]TypeMapping
 
-type JiraTransformationRule struct {
+type JiraScopeConfig struct {
+       Entities                   []string     `json:"entities"`
        ConnectionId               uint64       `mapstructure:"connectionId" 
json:"connectionId"`
        Name                       string       `gorm:"type:varchar(255)" 
validate:"required"`
        EpicKeyField               string       `json:"epicKeyField"`
@@ -50,7 +51,7 @@ type JiraTransformationRule struct {
        TypeMappings               TypeMappings `json:"typeMappings"`
 }
 
-func (r *JiraTransformationRule) ToDb() (*models.JiraTransformationRule, 
errors.Error) {
+func (r *JiraScopeConfig) ToDb() (*models.JiraScopeConfig, errors.Error) {
        blob, err := json.Marshal(r.TypeMappings)
        if err != nil {
                return nil, errors.Default.Wrap(err, "error marshaling 
TypeMappings")
@@ -59,7 +60,7 @@ func (r *JiraTransformationRule) ToDb() 
(*models.JiraTransformationRule, errors.
        if err != nil {
                return nil, errors.Default.Wrap(err, "error marshaling 
RemotelinkRepoPattern")
        }
-       rule := &models.JiraTransformationRule{
+       scopeConfig := &models.JiraScopeConfig{
                ConnectionId:               r.ConnectionId,
                Name:                       r.Name,
                EpicKeyField:               r.EpicKeyField,
@@ -68,13 +69,14 @@ func (r *JiraTransformationRule) ToDb() 
(*models.JiraTransformationRule, errors.
                RemotelinkRepoPattern:      remotelinkRepoPattern,
                TypeMappings:               blob,
        }
-       if err1 := rule.VerifyRegexp(); err1 != nil {
+       scopeConfig.Entities = r.Entities
+       if err1 := scopeConfig.VerifyRegexp(); err1 != nil {
                return nil, err1
        }
-       return rule, nil
+       return scopeConfig, nil
 }
 
-func MakeTransformationRules(rule models.JiraTransformationRule) 
(*JiraTransformationRule, errors.Error) {
+func MakeScopeConfig(rule models.JiraScopeConfig) (*JiraScopeConfig, 
errors.Error) {
        var typeMapping TypeMappings
        var err error
        if len(rule.TypeMappings) > 0 {
@@ -90,7 +92,8 @@ func MakeTransformationRules(rule 
models.JiraTransformationRule) (*JiraTransform
                        return nil, errors.Default.Wrap(err, "error 
unMarshaling RemotelinkRepoPattern")
                }
        }
-       result := &JiraTransformationRule{
+       result := &JiraScopeConfig{
+               Entities:                   rule.Entities,
                ConnectionId:               rule.ConnectionId,
                Name:                       rule.Name,
                EpicKeyField:               rule.EpicKeyField,
@@ -103,13 +106,13 @@ func MakeTransformationRules(rule 
models.JiraTransformationRule) (*JiraTransform
 }
 
 type JiraOptions struct {
-       ConnectionId         uint64 `json:"connectionId"`
-       BoardId              uint64 `json:"boardId"`
-       TimeAfter            string
-       TransformationRules  *JiraTransformationRule 
`json:"transformationRules"`
-       ScopeId              string
-       TransformationRuleId uint64
-       PageSize             int
+       ConnectionId  uint64 `json:"connectionId"`
+       BoardId       uint64 `json:"boardId"`
+       TimeAfter     string
+       ScopeConfig   *JiraScopeConfig `json:"scopeConfig"`
+       ScopeId       string
+       ScopeConfigId uint64
+       PageSize      int
 }
 
 type JiraTaskData struct {
diff --git a/backend/plugins/jira/tasks/task_data_test.go 
b/backend/plugins/jira/tasks/task_data_test.go
index 9824f922c..04088ac5b 100644
--- a/backend/plugins/jira/tasks/task_data_test.go
+++ b/backend/plugins/jira/tasks/task_data_test.go
@@ -25,18 +25,18 @@ import (
        "github.com/apache/incubator-devlake/plugins/jira/models"
 )
 
-func TestMakeTransformationRules(t *testing.T) {
+func TestMakeScopeConfigs(t *testing.T) {
        type args struct {
-               rule models.JiraTransformationRule
+               rule models.JiraScopeConfig
        }
        tests := []struct {
                name  string
                args  args
-               want  *JiraTransformationRule
+               want  *JiraScopeConfig
                want1 errors.Error
        }{
                {"non-null RemotelinkRepoPattern",
-                       args{rule: models.JiraTransformationRule{
+                       args{rule: models.JiraScopeConfig{
                                Name:                       "name",
                                EpicKeyField:               "epic",
                                StoryPointField:            "story",
@@ -44,7 +44,7 @@ func TestMakeTransformationRules(t *testing.T) {
                                RemotelinkRepoPattern:      
[]byte(`["abc","efg"]`),
                                TypeMappings:               
[]byte(`{"10040":{"standardType":"Incident","statusMappings":null}}`),
                        }},
-                       &JiraTransformationRule{
+                       &JiraScopeConfig{
                                Name:                       "name",
                                EpicKeyField:               "epic",
                                StoryPointField:            "story",
@@ -59,11 +59,11 @@ func TestMakeTransformationRules(t *testing.T) {
                },
 
                {"null RemotelinkRepoPattern",
-                       args{rule: models.JiraTransformationRule{
+                       args{rule: models.JiraScopeConfig{
                                RemotelinkRepoPattern: nil,
                                TypeMappings:          nil,
                        }},
-                       &JiraTransformationRule{
+                       &JiraScopeConfig{
                                RemotelinkRepoPattern: nil,
                                TypeMappings:          nil,
                        },
@@ -72,12 +72,12 @@ func TestMakeTransformationRules(t *testing.T) {
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       got, got1 := MakeTransformationRules(tt.args.rule)
+                       got, got1 := MakeScopeConfig(tt.args.rule)
                        if !reflect.DeepEqual(got, tt.want) {
-                               t.Errorf("MakeTransformationRules() got = %v, 
want %v", got, tt.want)
+                               t.Errorf("MakeScopeConfig() got = %v, want %v", 
got, tt.want)
                        }
                        if !reflect.DeepEqual(got1, tt.want1) {
-                               t.Errorf("MakeTransformationRules() got1 = %v, 
want %v", got1, tt.want1)
+                               t.Errorf("MakeScopeConfig() got1 = %v, want 
%v", got1, tt.want1)
                        }
                })
        }


Reply via email to