Class: Pindo::TaskSystem::JPSWorkFlowMessageTask

Inherits:
JPSTask show all
Defined in:
lib/pindo/module/task/model/jps/jps_workflow_message_task.rb

Overview

JPS 工作流消息发送任务使用 commit_log/send_message 接口发送 Git commit 消息到工作流

Instance Attribute Summary collapse

Attributes inherited from JPSTask

#app_info_obj, #project_name, #workflow_info

Attributes inherited from PindoTask

#callbacks_setup, #context, #created_at, #dependencies, #error, #finished_at, #id, #max_retry_count, #metadata, #name, #priority, #result, #retry_count, #retry_delay, #retry_mode, #skip_count, #started_at, #status, #task_key, #task_manager, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from JPSTask

default_retry_count, default_retry_delay, default_retry_mode, task_type, task_type_name

Methods inherited from PindoTask

#before_retry, #cancel, #cancelled?, #check_cancelled!, #data_param, default_retry_count, default_retry_delay, default_retry_mode, #do_task, #execution_time, #finished?, #get_all_data_params, #get_all_data_params_by_key, #get_all_dependencies_results, #get_data_param, #get_data_param_by_key, #get_dependency_result, #get_dependency_task, #on, #primary_data_param, #release_resource, #release_resources, #required_resources, #reset_for_retry, #retryable?, #running?, #should_retry?, task_type, #with_resource, #with_resources

Constructor Details

#initialize(options = {}) ⇒ JPSWorkFlowMessageTask

初始化工作流消息发送任务

Parameters:

  • options (Hash) (defaults to: {})

    选项

Options Hash (options):

  • :git_commit_id (String)

    Git commit SHA(可选,从依赖任务获取)

  • :git_commit_time (String)

    Git commit 时间(可选)

  • :git_commit_desc (String)

    Git commit 描述(可选)

  • :project_id (String)

    项目 ID(可选,从 app_info_obj 获取)

  • :workflow_id (Integer)

    工作流 ID(可选,从 workflow_info 获取)

  • :branch (String)

    分支名(可选,默认 ‘master’)

  • :single (Boolean)

    是否单个提交(默认 true)

  • :app_info_obj (Hash)

    JPS 应用信息对象(可选,用于获取 project_id)

  • :workflow_info (Hash)

    工作流信息(可选,用于获取 workflow_id)



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pindo/module/task/model/jps/jps_workflow_message_task.rb', line 29

def initialize(options = {})
  @git_commit_id = options[:git_commit_id]
  @git_commit_time = options[:git_commit_time]
  @git_commit_desc = options[:git_commit_desc]
  @project_id = options[:project_id]
  @workflow_id = options[:workflow_id]
  @branch = options[:branch] || 'master'
  @single = options.fetch(:single, true)

  # 消息发送任务优先级为 LOW,确保在其他任务之后执行
  options[:priority] ||= TaskPriority::LOW

  super("JPS 发送工作流消息", options)
end

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



11
12
13
# File 'lib/pindo/module/task/model/jps/jps_workflow_message_task.rb', line 11

def branch
  @branch
end

#git_commit_descObject (readonly)

Returns the value of attribute git_commit_desc.



10
11
12
# File 'lib/pindo/module/task/model/jps/jps_workflow_message_task.rb', line 10

def git_commit_desc
  @git_commit_desc
end

#git_commit_idObject (readonly)

Returns the value of attribute git_commit_id.



10
11
12
# File 'lib/pindo/module/task/model/jps/jps_workflow_message_task.rb', line 10

def git_commit_id
  @git_commit_id
end

#git_commit_timeObject (readonly)

Returns the value of attribute git_commit_time.



10
11
12
# File 'lib/pindo/module/task/model/jps/jps_workflow_message_task.rb', line 10

def git_commit_time
  @git_commit_time
end

#project_idObject (readonly)

Returns the value of attribute project_id.



11
12
13
# File 'lib/pindo/module/task/model/jps/jps_workflow_message_task.rb', line 11

def project_id
  @project_id
end

#workflow_idObject (readonly)

Returns the value of attribute workflow_id.



11
12
13
# File 'lib/pindo/module/task/model/jps/jps_workflow_message_task.rb', line 11

def workflow_id
  @workflow_id
end

Class Method Details

.task_keyObject

任务键



14
15
16
# File 'lib/pindo/module/task/model/jps/jps_workflow_message_task.rb', line 14

def self.task_key
  :jps_workflow_message
end

Instance Method Details

#validateObject



44
45
46
47
# File 'lib/pindo/module/task/model/jps/jps_workflow_message_task.rb', line 44

def validate
  # 参数可以从依赖任务获取,这里不做严格验证
  true
end