Module: Fastlane::Actions

Defined in:
lib/fastlane/actions/ipa.rb,
lib/fastlane/actions/say.rb,
lib/fastlane/actions/sigh.rb,
lib/fastlane/actions/slack.rb,
lib/fastlane/actions/hockey.rb,
lib/fastlane/actions/xctool.rb,
lib/fastlane/actions/deliver.rb,
lib/fastlane/actions/frameit.rb,
lib/fastlane/actions/hipchat.rb,
lib/fastlane/actions/produce.rb,
lib/fastlane/actions/snapshot.rb,
lib/fastlane/actions/testmunk.rb,
lib/fastlane/actions/deploygate.rb,
lib/fastlane/actions/crashlytics.rb,
lib/fastlane/actions/actions_helper.rb,
lib/fastlane/actions/install_cocapods.rb,
lib/fastlane/actions/increment_build_number.rb

Defined Under Namespace

Modules: SharedValues Classes: CocoapodsAction, CrashlyticsAction, DeliverAction, DeploygateAction, FrameitAction, HipchatAction, HockeyAction, IncrementBuildNumberAction, IpaAction, ProduceAction, SayAction, SighAction, SlackAction, SnapshotAction, TestmunkAction, XctoolAction

Constant Summary collapse

ARGS_MAP =

-w, –workspace WORKSPACE Workspace (.xcworkspace) file to use to build app (automatically detected in current directory) -p, –project PROJECT Project (.xcodeproj) file to use to build app (automatically detected in current directory, overridden by –workspace option, if passed) -c, –configuration CONFIGURATION Configuration used to build -s, –scheme SCHEME Scheme used to build app –xcconfig XCCONFIG use an extra XCCONFIG file to build the app –xcargs XCARGS pass additional arguments to xcodebuild when building the app. Be sure to quote multiple args. –[no-]clean Clean project before building –[no-]archive Archive project after building -d, –destination DESTINATION Destination. Defaults to current directory -m, –embed PROVISION Sign .ipa file with .mobileprovision -i, –identity IDENTITY Identity to be used along with –embed –sdk SDK use SDK as the name or path of the base SDK when building the project –ipa IPA specify the name of the .ipa file to generate (including file extension)

{
  workspace: '-w',
  project: '-p',
  configuration: '-c',
  scheme: '-s',
  clean: '--clean',
  archive: '--archive',
  destination: '-d',
  embed: '-m',
  identity: '-i',
  sdk: '--sdk',
  ipa: '--ipa'
}

Class Method Summary collapse

Class Method Details

.execute_action(step_name) ⇒ Object

Pass a block which should be tracked. One block = one testcase

Parameters:

  • step_name (String)

    the name of the currently built code (e.g. snapshot, sigh, …)



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fastlane/actions/actions_helper.rb', line 20

def self.execute_action(step_name)
  raise "No block given".red unless block_given?
  
  start = Time.now
  error = nil
  exc = nil

  begin
    yield
  rescue => ex
    exc = ex
    error = caller.join("\n") + "\n\n" + ex.to_s
  end
ensure
  # This is also called, when the block has a return statement
  duration = Time.now - start

  self.executed_actions << {
    name: step_name,
    error: error,
    time: duration
    # output: captured_output
  }
  raise exc if exc
end

.executed_actionsObject



9
10
11
# File 'lib/fastlane/actions/actions_helper.rb', line 9

def self.executed_actions
  @@executed_actions ||= []
end

.lane_contextObject

The shared hash can be accessed by any action and contains information like the screenshots path or beta URL



14
15
16
# File 'lib/fastlane/actions/actions_helper.rb', line 14

def self.lane_context
  @@lane_context ||= {}
end

.load_default_actionsObject



78
79
80
81
82
# File 'lib/fastlane/actions/actions_helper.rb', line 78

def self.load_default_actions
  Dir[File.expand_path '*.rb', File.dirname(__FILE__)].each do |file|
    require file
  end
end

.load_external_actions(path) ⇒ Object



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
# File 'lib/fastlane/actions/actions_helper.rb', line 84

def self.load_external_actions(path)
  raise "You need to pass a valid path" unless File.exists?path

  Dir[File.expand_path '*.rb', path].each do |file|
    require file
    
    file_name = File.basename(file).gsub(".rb", "")

    class_name = file_name.classify + "Action"
    class_ref = nil
    begin
      class_ref = Fastlane::Actions.const_get(class_name)

      if class_ref.respond_to?(:run)
        Helper.log.info "Successfully loaded custom action '#{file}'.".green
      else
        Helper.log.error "Could not find method 'run' in class #{class_name}.".red
        Helper.log.error "For more information, check out the docs: https://github.com/KrauseFx/fastlane"
        raise "Plugin '#{file_name}' is damaged!"
      end
    rescue NameError => ex
      # Action not found
      Helper.log.error "Could not find '#{class_name}' class defined.".red
      Helper.log.error "For more information, check out the docs: https://github.com/KrauseFx/fastlane"
      raise "Plugin '#{file_name}' is damaged!"
    end
  end
end

.sh(command) ⇒ Object

Execute a shell command This method will output the string and execute it



48
49
50
# File 'lib/fastlane/actions/actions_helper.rb', line 48

def self.sh(command)
  return sh_no_action(command)
end

.sh_no_action(command) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/fastlane/actions/actions_helper.rb', line 52

def self.sh_no_action(command)
  command = command.join(" ") if command.kind_of?Array # since it's an array of one element when running from the Fastfile
  Helper.log.info ["[SHELL COMMAND]", command.yellow].join(': ')

  result = ""
  unless Helper.is_test?

    PTY.spawn(command) do |stdin, stdout, pid|
      stdin.each do |line|
        Helper.log.info ["[SHELL OUTPUT]", line.strip].join(': ')
        result << line
      end

      Process.wait(pid)
    end

    if $?.exitstatus.to_i != 0
      raise "Exit status of command '#{command}' was #{$?.exitstatus.to_s} instead of 0. \n#{result}" # this will also append the output to the exception (for the Jenkins reports)
    end
  else
    result << command # only for the tests
  end

  return result
end