Class: Fastlane::Actions::PerfectoAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/perfecto/actions/perfecto_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



45
46
47
# File 'lib/fastlane/plugin/perfecto/actions/perfecto_action.rb', line 45

def self.authors
  ["genesisthomas"]
end

.available_optionsObject



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/fastlane/plugin/perfecto/actions/perfecto_action.rb', line 80

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :perfecto_cloudurl,
                                 description: "Perfecto's cloud url",
                                 optional: false,
                                 is_string: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("No perfecto_cloudurl given.") if value.to_s.empty?
                                 end),
    FastlaneCore::ConfigItem.new(key: :perfecto_token,
                                 description: "Perfecto's security token",
                                 optional: false,
                                 is_string: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("No perfecto_token given.") if value.to_s.empty?
                                 end),
    FastlaneCore::ConfigItem.new(key: :perfecto_media_location,
                                 description: "Path to Perfecto media location",
                                 optional: false,
                                 is_string: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("No perfecto_media_location given.") if value.to_s.empty?
                                 end),
    FastlaneCore::ConfigItem.new(key: :artifactType,
                                 description: "Optional, Artifact types: GENERAL, IOS, SIMULATOR, ANDROID, IMAGE, AUDIO, VIDEO, SCRIPT",
                                 optional: true,
                                 default_value: "",
                                 is_string: true),
    FastlaneCore::ConfigItem.new(key: :artifactName,
                                 description: "Optional, Used for the representation of the artifact when downloaded",
                                 optional: true,
                                 default_value: "",
                                 is_string: true),
    FastlaneCore::ConfigItem.new(key: :file_path,
                                 description: "Path to the app file",
                                 optional: true,
                                 is_string: true,
                                 default_value: default_file_path)
  ]
end

.default_file_pathObject



69
70
71
72
73
74
75
76
77
78
# File 'lib/fastlane/plugin/perfecto/actions/perfecto_action.rb', line 69

def self.default_file_path
  platform = Actions.lane_context[Actions::SharedValues::PLATFORM_NAME]
  if platform == :ios
    # Shared value for ipa path if it was generated by gym https://docs.fastlane.tools/actions/gym/.
    return Actions.lane_context[Actions::SharedValues::IPA_OUTPUT_PATH]
  else
    # Shared value for apk if it was generated by gradle.
    return Actions.lane_context[Actions::SharedValues::GRADLE_APK_OUTPUT_PATH]
  end
end

.descriptionObject



41
42
43
# File 'lib/fastlane/plugin/perfecto/actions/perfecto_action.rb', line 41

def self.description
  "This plugin allows you to automatically upload ipa/apk files to Perfecto for manual/automation testing"
end

.detailsObject



53
54
55
56
# File 'lib/fastlane/plugin/perfecto/actions/perfecto_action.rb', line 53

def self.details
  # Optional:
  "A fastlane plugin which aids in automated deployment of ipa/apk files to Perfecto iOS/Android devices"
end

.example_codeObject



125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/fastlane/plugin/perfecto/actions/perfecto_action.rb', line 125

def self.example_code
  [
    "perfecto",
    'perfecto(
      perfecto_cloudurl: ENV["PERFECTO_CLOUDURL"],
      perfecto_token: ENV["PERFECTO_TOKEN"],
      perfecto_media_location: ENV["PERFECTO_MEDIA_LOCATION"],
      file_path: "path_to_apk_or_ipa_file",
      artifactType: ENV["artifactType"],
      artifactName: ENV["artifactName"]
     )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


121
122
123
# File 'lib/fastlane/plugin/perfecto/actions/perfecto_action.rb', line 121

def self.is_supported?(platform)
  [:ios, :android].include?(platform)
end

.outputObject



63
64
65
66
67
# File 'lib/fastlane/plugin/perfecto/actions/perfecto_action.rb', line 63

def self.output
  [
    ["perfecto_media_fullpath", "Perfecto media repo location"]
  ]
end

.return_valueObject



49
50
51
# File 'lib/fastlane/plugin/perfecto/actions/perfecto_action.rb', line 49

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fastlane/plugin/perfecto/actions/perfecto_action.rb', line 12

def self.run(params)
  # Mandatory parameters
  perfecto_cloudurl = params[:perfecto_cloudurl]
  perfecto_token = params[:perfecto_token]
  filepath = params[:file_path].to_s
  perfecto_media_fullpath = params[:perfecto_media_location]
  artifact_type = params[:artifactType] || ""
  artifact_nme = params[:artifactName] || ""

  # validates the filepath and perfecto media location file
  UI.message("validating filepath")
  validate_filepath(filepath)
  UI.message("validating media location")

  # uploads the ipa/apk to perfecto media repository
  UI.message("Attempting to upload: " + filepath + " to Perfecto!")
  # Helper::PerfectoHelper.upload_file(perfecto_cloudurl, perfecto_token, filepath, perfecto_media_fullpath)
  Helper::PerfectoHelper.upload_v1(perfecto_cloudurl, perfecto_token, filepath, perfecto_media_fullpath, artifact_type, artifact_nme)
  UI.success("The File in: " + filepath + " is successfully uploaded to Perfecto media location : " + perfecto_media_fullpath)

  # Setting the environment variable: PERFECTO_MEDIA_FULLPATH with the perfecto media repository location.
  ENV["PERFECTO_MEDIA_FULLPATH"] = nil
  ENV["PERFECTO_MEDIA_FULLPATH"] = perfecto_media_fullpath
  UI.success("Setting Environment variable PERFECTO_MEDIA_FULLPATH = " + ENV["PERFECTO_MEDIA_FULLPATH"])

  # Setting the media fullpath in shared values post successful upload in order to be used by other fastlane actions.
  Actions.lane_context[SharedValues::PERFECTO_MEDIA_FULLPATH] = perfecto_media_fullpath
end

.validate_filepath(filepath) ⇒ Object

Validate filepath.



59
60
61
# File 'lib/fastlane/plugin/perfecto/actions/perfecto_action.rb', line 59

def self.validate_filepath(filepath)
  UI.user_error!("No file found at filepath parameter location.") unless File.exist?(filepath)
end