diff --git a/pkg/microservice/aslan/core/common/repository/models/wokflow_task_v4.go b/pkg/microservice/aslan/core/common/repository/models/wokflow_task_v4.go index 0d5df42a29..60477fc419 100644 --- a/pkg/microservice/aslan/core/common/repository/models/wokflow_task_v4.go +++ b/pkg/microservice/aslan/core/common/repository/models/wokflow_task_v4.go @@ -23,26 +23,27 @@ import ( ) type WorkflowTask struct { - ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"` - TaskID int64 `bson:"task_id" json:"task_id"` - WorkflowName string `bson:"workflow_name" json:"workflow_name"` - Params []*Param `bson:"params" json:"params"` - WorkflowArgs *WorkflowV4 `bson:"workflow_args" json:"workflow_args"` - KeyVals []*KeyVal `bson:"key_vals" json:"key_vals"` - GlobalContext map[string]string `bson:"global_context" json:"global_context"` - Status config.Status `bson:"status" json:"status,omitempty"` - TaskCreator string `bson:"task_creator" json:"task_creator,omitempty"` - TaskRevoker string `bson:"task_revoker,omitempty" json:"task_revoker,omitempty"` - CreateTime int64 `bson:"create_time" json:"create_time,omitempty"` - StartTime int64 `bson:"start_time" json:"start_time,omitempty"` - EndTime int64 `bson:"end_time" json:"end_time,omitempty"` - Stages []*StageTask `bson:"stages" json:"stages"` - ProjectName string `bson:"project_name,omitempty" json:"project_name,omitempty"` - IsDeleted bool `bson:"is_deleted" json:"is_deleted"` - IsArchived bool `bson:"is_archived" json:"is_archived"` - Error string `bson:"error,omitempty" json:"error,omitempty"` - IsRestart bool `bson:"is_restart" json:"is_restart"` - MultiRun bool `bson:"multi_run" json:"multi_run"` + ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"` + TaskID int64 `bson:"task_id" json:"task_id"` + WorkflowName string `bson:"workflow_name" json:"workflow_name"` + Params []*Param `bson:"params" json:"params"` + WorkflowArgs *WorkflowV4 `bson:"workflow_args" json:"workflow_args"` + OriginWorkflowArgs *WorkflowV4 `bson:"origin_workflow_args" json:"origin_workflow_args"` + KeyVals []*KeyVal `bson:"key_vals" json:"key_vals"` + GlobalContext map[string]string `bson:"global_context" json:"global_context"` + Status config.Status `bson:"status" json:"status,omitempty"` + TaskCreator string `bson:"task_creator" json:"task_creator,omitempty"` + TaskRevoker string `bson:"task_revoker,omitempty" json:"task_revoker,omitempty"` + CreateTime int64 `bson:"create_time" json:"create_time,omitempty"` + StartTime int64 `bson:"start_time" json:"start_time,omitempty"` + EndTime int64 `bson:"end_time" json:"end_time,omitempty"` + Stages []*StageTask `bson:"stages" json:"stages"` + ProjectName string `bson:"project_name,omitempty" json:"project_name,omitempty"` + IsDeleted bool `bson:"is_deleted" json:"is_deleted"` + IsArchived bool `bson:"is_archived" json:"is_archived"` + Error string `bson:"error,omitempty" json:"error,omitempty"` + IsRestart bool `bson:"is_restart" json:"is_restart"` + MultiRun bool `bson:"multi_run" json:"multi_run"` } func (WorkflowTask) TableName() string { diff --git a/pkg/microservice/aslan/core/workflow/service/workflow/workflow_task_v4.go b/pkg/microservice/aslan/core/workflow/service/workflow/workflow_task_v4.go index 5cbcb758bd..3c70c332df 100644 --- a/pkg/microservice/aslan/core/workflow/service/workflow/workflow_task_v4.go +++ b/pkg/microservice/aslan/core/workflow/service/workflow/workflow_task_v4.go @@ -123,6 +123,13 @@ func CreateWorkflowTaskV4(user string, workflow *commonmodels.WorkflowV4, log *z return resp, err } workflowTask := &commonmodels.WorkflowTask{} + // save workflow original workflow task args. + originTaskArgs := &commonmodels.WorkflowV4{} + if err := commonmodels.IToi(workflow, originTaskArgs); err != nil { + log.Errorf("save original workflow args error: %v", err) + return resp, e.ErrCreateTask.AddDesc(err.Error()) + } + workflowTask.OriginWorkflowArgs = originTaskArgs nextTaskID, err := commonrepo.NewCounterColl().GetNextSeq(fmt.Sprintf(setting.WorkflowTaskV4Fmt, workflow.Name)) if err != nil { log.Errorf("Counter.GetNextSeq error: %v", err) @@ -210,7 +217,7 @@ func CloneWorkflowTaskV4(workflowName string, taskID int64, logger *zap.SugaredL logger.Errorf("find workflowTaskV4 error: %s", err) return nil, e.ErrGetTask.AddErr(err) } - return task.WorkflowArgs, nil + return task.OriginWorkflowArgs, nil } func UpdateWorkflowTaskV4(id string, workflowTask *commonmodels.WorkflowTask, logger *zap.SugaredLogger) error {