diff --git a/internal/workflow/dispatcher/dispatcher.go b/internal/workflow/dispatcher/dispatcher.go index ff46b5b6e..dbd662223 100644 --- a/internal/workflow/dispatcher/dispatcher.go +++ b/internal/workflow/dispatcher/dispatcher.go @@ -316,11 +316,13 @@ func (wd *workflowDispatcher) tryExecuteAsync(task *taskInfo) { // 执行工作流 wd.syslog.Info(fmt.Sprintf("workflow #%s's run #%s started", task.WorkflowId, task.RunId)) we.Invoke(task.ctx, engine.WorkflowExecution{ - WorkflowId: workflowRun.WorkflowId, - WorkflowName: workflow.Name, - RunId: workflowRun.Id, - RunTrigger: workflowRun.Trigger, - Graph: workflowRun.Graph, + WorkflowId: workflow.Id, + WorkflowName: workflow.Name, + WorkflowDescription: workflow.Description, + RunId: workflowRun.Id, + RunTrigger: workflowRun.Trigger, + RunAt: workflowRun.StartedAt, + Graph: workflowRun.Graph, }) wd.syslog.Info(fmt.Sprintf("workflow #%s's run #%s stopped", task.WorkflowId, task.RunId)) } diff --git a/internal/workflow/engine/engine.go b/internal/workflow/engine/engine.go index 86d8d8fc2..178eb42df 100644 --- a/internal/workflow/engine/engine.go +++ b/internal/workflow/engine/engine.go @@ -7,6 +7,7 @@ import ( "log/slog" "runtime/debug" "sync" + "time" "github.com/samber/lo" @@ -17,11 +18,13 @@ import ( ) type WorkflowExecution struct { - WorkflowId string - WorkflowName string - RunId string - RunTrigger domain.WorkflowTriggerType - Graph *Graph + WorkflowId string + WorkflowName string + WorkflowDescription string + RunId string + RunTrigger domain.WorkflowTriggerType + RunAt time.Time + Graph *Graph } type WorkflowEngine interface { @@ -71,6 +74,7 @@ func (we *workflowEngine) Invoke(ctx context.Context, execution WorkflowExecutio wfVars := newVariableManager() wfVars.Set(stateVarKeyWorkflowId, execution.WorkflowId, stateValTypeString) wfVars.Set(stateVarKeyWorkflowName, execution.WorkflowName, stateValTypeString) + wfVars.Set(stateVarKeyWorkflowDescription, execution.WorkflowDescription, stateValTypeString) wfVars.Set(stateVarKeyRunId, execution.RunId, stateValTypeString) wfVars.Set(stateVarKeyRunTrigger, execution.RunTrigger, stateValTypeString) wfVars.Set(stateVarKeyErrorNodeId, "", stateValTypeString) diff --git a/internal/workflow/engine/state.go b/internal/workflow/engine/state.go index ce0fa60a6..70afe06bd 100644 --- a/internal/workflow/engine/state.go +++ b/internal/workflow/engine/state.go @@ -292,6 +292,7 @@ const ( const ( stateVarKeyWorkflowId = "workflow.id" // ValueType: "string" stateVarKeyWorkflowName = "workflow.name" // ValueType: "string" + stateVarKeyWorkflowDescription = "workflow.description" // ValueType: "string" stateVarKeyRunId = "run.id" // ValueType: "string" stateVarKeyRunTrigger = "run.trigger" // ValueType: "string" stateVarKeyNodeId = "node.id" // ValueType: "string" diff --git a/ui/src/i18n/locales/en/nls.workflow.nodes.json b/ui/src/i18n/locales/en/nls.workflow.nodes.json index 8796db9c9..309f087c3 100644 --- a/ui/src/i18n/locales/en/nls.workflow.nodes.json +++ b/ui/src/i18n/locales/en/nls.workflow.nodes.json @@ -1279,7 +1279,7 @@ "workflow_node.notify.form.subject.placeholder": "Please enter subject", "workflow_node.notify.form.message.label": "Message", "workflow_node.notify.form.message.placeholder": "Please enter message", - "workflow_node.notify.form.template.guide": "
The content using the \"Mustache\" syntax (double curly braces) and preceded by \"$\" in the subject or message are text interpolations. They will be replaced by the actual values.
Supported text interpolations:
  1. Workflow:
    1. workflow.id: The ID of the workflow.
    2. workflow.name: The name of the workflow.
    3. run.id: The ID of the workflow run.
  2. Error:
    (If there are multiple nodes that have failed before this, it always indicate the nearest one.)
    1. error.nodeId: The node ID that execution failed.
    2. error.nodeName: The node name that execution failed.
    3. error.message: The error message that execution failed.
  3. Certificate:
    (If there are multiple nodes outputting a certificate before this, it always indicate the nearest one.)
    1. certificate.commonName: The primary domain or IP address of the certificate.
    2. certificate.subjectAltNames: The domains or IP addresses of the certificate, separated by semicolons.
    3. certificate.notBefore: The effect time of the certificate, formatted in RFC3339.
    4. certificate.notAfter: The expire time of the certificate, formatted in RFC3339.
    5. certificate.hoursLeft: The left hours of the certificate.
    6. certificate.daysLeft: The left days of the certificate.
    7. certificate.validity: The validity of the certificate.
  4. Other:
    1. now: The current time on the server, formatted in RFC3339.

Example:
Your workflow {{ $workflow.name }} has failed on node {{ $error.nodeName }} at {{ $now }}.
", + "workflow_node.notify.form.template.guide": "
The content using the \"Mustache\" syntax (double curly braces) and preceded by \"$\" in the subject or message are text interpolations. They will be replaced by the actual values.
Supported text interpolations:
  1. Workflow:
    1. workflow.id: The ID of the workflow.
    2. workflow.name: The name of the workflow.
    3. workflow.description: The description of the workflow.
    4. run.id: The ID of the workflow run.
  2. Error:
    (If there are multiple nodes that have failed before this, it always indicate the nearest one.)
    1. error.nodeId: The node ID that execution failed.
    2. error.nodeName: The node name that execution failed.
    3. error.message: The error message that execution failed.
  3. Certificate:
    (If there are multiple nodes outputting a certificate before this, it always indicate the nearest one.)
    1. certificate.commonName: The primary domain or IP address of the certificate.
    2. certificate.subjectAltNames: The domains or IP addresses of the certificate, separated by semicolons.
    3. certificate.notBefore: The effect time of the certificate, formatted in RFC3339.
    4. certificate.notAfter: The expire time of the certificate, formatted in RFC3339.
    5. certificate.hoursLeft: The left hours of the certificate.
    6. certificate.daysLeft: The left days of the certificate.
    7. certificate.validity: The validity of the certificate.
  4. Other:
    1. now: The current time on the server, formatted in RFC3339.

Example:
Your workflow {{ $workflow.name }} has failed on node {{ $error.nodeName }} at {{ $now }}.
", "workflow_node.notify.form.provider.label": "Notification channel", "workflow_node.notify.form.provider.placeholder": "Please select notification channel", "workflow_node.notify.form.provider.search.placeholder": "Search notification channel ...", diff --git a/ui/src/i18n/locales/zh/nls.workflow.nodes.json b/ui/src/i18n/locales/zh/nls.workflow.nodes.json index 6d4c2d294..f5a3fe0b8 100644 --- a/ui/src/i18n/locales/zh/nls.workflow.nodes.json +++ b/ui/src/i18n/locales/zh/nls.workflow.nodes.json @@ -1277,7 +1277,7 @@ "workflow_node.notify.form.subject.placeholder": "请输入通知主题", "workflow_node.notify.form.message.label": "通知内容", "workflow_node.notify.form.message.placeholder": "请输入通知内容", - "workflow_node.notify.form.template.guide": "
通知主题或内容中使用「Mustache」语法(即双大括号)包裹、并以「$」符号开头的文本会被视为模板插值,将在推送时被替换为实际值。
支持的模板插值:
  1. 工作流相关:
    1. workflow.id:工作流 ID。
    2. workflow.name:工作流名称。
    3. run.id:运行 ID。
  2. 异常相关:
    (如果在此之前有多个执行失败的节点,始终表示最近的一个。)
    1. error.nodeId:执行失败时的节点 ID。
    2. error.nodeName:执行失败时的节点名称。
    3. error.message:执行失败时的错误信息。
  3. 证书相关:
    (如果在此之前有多个输出证书的节点,始终表示最近的一个。)
    1. certificate.commonName:证书主域名或 IP。
    2. certificate.subjectAltNames:证书多域名或 IP,以半角分号隔开。
    3. certificate.notBefore:证书生效时间,以 RFC3339 格式化。
    4. certificate.notAfter:证书过期时间,以 RFC3339 格式化。
    5. certificate.hoursLeft:证书剩余小时数。
    6. certificate.daysLeft:证书剩余天数。
    7. certificate.validity:证书是否有效。
  4. 其他:
    1. now:服务器当前时间,以 RFC3339 格式化。

示例:
Your workflow {{ $workflow.name }} has failed on node {{ $error.nodeName }} at {{ $now }}.
", + "workflow_node.notify.form.template.guide": "
通知主题或内容中使用「Mustache」语法(即双大括号)包裹、并以「$」符号开头的文本会被视为模板插值,将在推送时被替换为实际值。
支持的模板插值:
  1. 工作流相关:
    1. workflow.id:工作流 ID。
    2. workflow.name:工作流名称。
    3. workflow.description:工作流描述。
    4. run.id:运行 ID。
  2. 异常相关:
    (如果在此之前有多个执行失败的节点,始终表示最近的一个。)
    1. error.nodeId:执行失败时的节点 ID。
    2. error.nodeName:执行失败时的节点名称。
    3. error.message:执行失败时的错误信息。
  3. 证书相关:
    (如果在此之前有多个输出证书的节点,始终表示最近的一个。)
    1. certificate.commonName:证书主域名或 IP。
    2. certificate.subjectAltNames:证书多域名或 IP,以半角分号隔开。
    3. certificate.notBefore:证书生效时间,以 RFC3339 格式化。
    4. certificate.notAfter:证书过期时间,以 RFC3339 格式化。
    5. certificate.hoursLeft:证书剩余小时数。
    6. certificate.daysLeft:证书剩余天数。
    7. certificate.validity:证书是否有效。
  4. 其他:
    1. now:服务器当前时间,以 RFC3339 格式化。

示例:
Your workflow {{ $workflow.name }} has failed on node {{ $error.nodeName }} at {{ $now }}.
", "workflow_node.notify.form.provider.label": "通知渠道", "workflow_node.notify.form.provider.placeholder": "请选择通知渠道", "workflow_node.notify.form.provider.search.placeholder": "搜索通知渠道……",