Class: Pindo::TaskSystem::JPSUploadTask

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

Overview

JPS 上传任务上传构建产物到 JPS 测试平台

Instance Attribute Summary collapse

Attributes inherited from JPSTask

#app_info_obj, #project_name, #workflow_info

Attributes inherited from PindoTask

#callbacks_setup, #context, #created_at, #data_dependencies, #dependencies, #error, #finished_at, #id, #max_retry_count, #metadata, #name, #priority, #result, #retry_count, #retry_delay, #retry_mode, #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, #reset_for_retry, #retryable?, #running?, #should_retry?, task_type

Constructor Details

#initialize(file_type, upload_path, upload_file, options = {}) ⇒ JPSUploadTask

初始化上传任务

Parameters:

  • file_type (String)

    文件类型:‘ipa’ | ‘apk’ | ‘html’ | ‘app’

  • upload_path (String)

    搜索文件的路径

  • upload_file (String)

    要上传的文件(nil 表示自动查找)

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

    选项

Options Hash (options):

  • :app_info_obj (Hash)

    JPS 应用信息对象(可选,如为 nil 则延迟获取)

  • :workflow_info (Hash)

    工作流信息(可选,如为 nil 则延迟获取)

  • :project_name (String)

    项目名称(可选)

  • :upload_desc (String)

    上传描述(可选)



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/pindo/module/task/model/jps/jps_upload_task.rb', line 26

def initialize(file_type, upload_path, upload_file, options = {})
  @file_type = file_type        # 'ipa' | 'apk' | 'html' | 'app'
  @upload_path = upload_path    # 搜索文件的路径
  @upload_file = upload_file    # 要上传的文件(nil 表示自动查找)
  @upload_desc = options[:upload_desc]  # 上传描述

  # 设置上传任务的优先级为 LOW,确保在构建任务之后执行
  options[:priority] ||= TaskPriority::LOW

  name = case file_type
         when 'ipa'
           "上传 IPA"
         when 'apk'
           "上传 APK"
         when 'html'
           "上传 WebGL"
         when 'app'
           "上传 macOS App"
         else
           "上传 #{file_type.upcase}"
         end

  super(name, options)
end

Instance Attribute Details

#file_typeObject (readonly)

Returns the value of attribute file_type.



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

def file_type
  @file_type
end

#upload_fileObject (readonly)

Returns the value of attribute upload_file.



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

def upload_file
  @upload_file
end

#upload_pathObject (readonly)

Returns the value of attribute upload_path.



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

def upload_path
  @upload_path
end

Class Method Details

.task_keyObject

任务键



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

def self.task_key
  :jps_upload
end

Instance Method Details

#validateObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/pindo/module/task/model/jps/jps_upload_task.rb', line 51

def validate
  # 验证基本参数
  unless @file_type && !@file_type.empty?
    @error = "缺少必需参数: file_type"
    return false
  end

  unless @upload_path && !@upload_path.empty?
    @error = "缺少必需参数: upload_path"
    return false
  end

  # upload_path 可能在构建任务执行后才创建,这里不验证是否存在
  # 实际文件查找会在 do_work 中进行

  # app_info_obj 和 workflow_info 可以延迟获取,不在这里验证

  true
end