Module: Fastlane::Actions

Defined in:
lib/fastlane/actions/s3.rb,
lib/fastlane/actions/adb.rb,
lib/fastlane/actions/erb.rb,
lib/fastlane/actions/gym.rb,
lib/fastlane/actions/ipa.rb,
lib/fastlane/actions/pem.rb,
lib/fastlane/actions/say.rb,
lib/fastlane/actions/scp.rb,
lib/fastlane/actions/ssh.rb,
lib/fastlane/actions/zip.rb,
lib/fastlane/actions/cert.rb,
lib/fastlane/actions/cloc.rb,
lib/fastlane/actions/lcov.rb,
lib/fastlane/actions/puts.rb,
lib/fastlane/actions/scan.rb,
lib/fastlane/actions/sigh.rb,
lib/fastlane/actions/xcov.rb,
lib/fastlane/actions/badge.rb,
lib/fastlane/actions/debug.rb,
lib/fastlane/actions/gcovr.rb,
lib/fastlane/actions/ifttt.rb,
lib/fastlane/actions/is_ci.rb,
lib/fastlane/actions/jazzy.rb,
lib/fastlane/actions/match.rb,
lib/fastlane/actions/pilot.rb,
lib/fastlane/actions/rsync.rb,
lib/fastlane/actions/slack.rb,
lib/fastlane/actions/sonar.rb,
lib/fastlane/actions/xcake.rb,
lib/fastlane/actions/appium.rb,
lib/fastlane/actions/gradle.rb,
lib/fastlane/actions/hockey.rb,
lib/fastlane/actions/import.rb,
lib/fastlane/actions/notify.rb,
lib/fastlane/actions/oclint.rb,
lib/fastlane/actions/prompt.rb,
lib/fastlane/actions/resign.rb,
lib/fastlane/actions/rocket.rb,
lib/fastlane/actions/supply.rb,
lib/fastlane/actions/xctool.rb,
lib/fastlane/actions/deliver.rb,
lib/fastlane/actions/frameit.rb,
lib/fastlane/actions/git_add.rb,
lib/fastlane/actions/hg_push.rb,
lib/fastlane/actions/hipchat.rb,
lib/fastlane/actions/mailgun.rb,
lib/fastlane/actions/produce.rb,
lib/fastlane/actions/slather.rb,
lib/fastlane/actions/team_id.rb,
lib/fastlane/actions/tryouts.rb,
lib/fastlane/actions/twitter.rb,
lib/fastlane/actions/appetize.rb,
lib/fastlane/actions/appledoc.rb,
lib/fastlane/actions/appstore.rb,
lib/fastlane/actions/carthage.rb,
lib/fastlane/actions/chatwork.rb,
lib/fastlane/actions/download.rb,
lib/fastlane/actions/dsym_zip.rb,
lib/fastlane/actions/git_pull.rb,
lib/fastlane/actions/installr.rb,
lib/fastlane/actions/pod_push.rb,
lib/fastlane/actions/snapshot.rb,
lib/fastlane/actions/testmunk.rb,
lib/fastlane/actions/typetalk.rb,
lib/fastlane/helper/sh_helper.rb,
lib/fastlane/actions/appaloosa.rb,
lib/fastlane/actions/clipboard.rb,
lib/fastlane/actions/cocoapods.rb,
lib/fastlane/actions/onesignal.rb,
lib/fastlane/actions/skip_docs.rb,
lib/fastlane/actions/swiftlint.rb,
lib/fastlane/actions/team_name.rb,
lib/fastlane/actions/testfairy.rb,
lib/fastlane/helper/gem_helper.rb,
lib/fastlane/helper/git_helper.rb,
lib/fastlane/actions/deploygate.rb,
lib/fastlane/actions/git_branch.rb,
lib/fastlane/actions/git_commit.rb,
lib/fastlane/actions/hg_add_tag.rb,
lib/fastlane/actions/podio_item.rb,
lib/fastlane/actions/screengrab.rb,
lib/fastlane/actions/splunkmint.rb,
lib/fastlane/actions/testflight.rb,
lib/fastlane/actions/xcodebuild.rb,
lib/fastlane/actions/adb_devices.rb,
lib/fastlane/actions/add_git_tag.rb,
lib/fastlane/actions/artifactory.rb,
lib/fastlane/actions/backup_file.rb,
lib/fastlane/actions/crashlytics.rb,
lib/fastlane/actions/lane_context.rb,
lib/fastlane/actions/last_git_tag.rb,
lib/fastlane/actions/nexus_upload.rb,
lib/fastlane/actions/notification.rb,
lib/fastlane/actions/read_podspec.rb,
lib/fastlane/actions/restore_file.rb,
lib/fastlane/actions/verify_build.rb,
lib/fastlane/actions/verify_xcode.rb,
lib/fastlane/actions/xcode_select.rb,
lib/fastlane/actions/opt_out_usage.rb,
lib/fastlane/actions/push_git_tags.rb,
lib/fastlane/actions/set_changelog.rb,
lib/fastlane/actions/setup_jenkins.rb,
lib/fastlane/actions/xcode_install.rb,
lib/fastlane/actions/actions_helper.rb,
lib/fastlane/actions/bundle_install.rb,
lib/fastlane/actions/copy_artifacts.rb,
lib/fastlane/actions/download_dsyms.rb,
lib/fastlane/actions/reset_git_repo.rb,
lib/fastlane/actions/create_keychain.rb,
lib/fastlane/actions/delete_keychain.rb,
lib/fastlane/actions/import_from_git.rb,
lib/fastlane/actions/last_git_commit.rb,
lib/fastlane/actions/unlock_keychain.rb,
lib/fastlane/actions/update_fastlane.rb,
lib/fastlane/actions/verify_pod_keys.rb,
lib/fastlane/actions/backup_xcarchive.rb,
lib/fastlane/actions/default_platform.rb,
lib/fastlane/actions/fastlane_version.rb,
lib/fastlane/actions/get_build_number.rb,
lib/fastlane/actions/recreate_schemes.rb,
lib/fastlane/actions/register_devices.rb,
lib/fastlane/actions/reset_simulators.rb,
lib/fastlane/actions/ensure_git_branch.rb,
lib/fastlane/actions/install_on_device.rb,
lib/fastlane/actions/number_of_commits.rb,
lib/fastlane/actions/update_info_plist.rb,
lib/fastlane/actions/clear_derived_data.rb,
lib/fastlane/actions/dotgpg_environment.rb,
lib/fastlane/actions/get_github_release.rb,
lib/fastlane/actions/get_version_number.rb,
lib/fastlane/actions/import_certificate.rb,
lib/fastlane/actions/push_to_git_remote.rb,
lib/fastlane/actions/set_github_release.rb,
lib/fastlane/actions/update_url_schemes.rb,
lib/fastlane/actions/commit_version_bump.rb,
lib/fastlane/actions/create_pull_request.rb,
lib/fastlane/actions/update_project_team.rb,
lib/fastlane/actions/version_get_podspec.rb,
lib/fastlane/actions/ensure_no_debug_code.rb,
lib/fastlane/actions/ensure_xcode_version.rb,
lib/fastlane/actions/get_info_plist_value.rb,
lib/fastlane/actions/install_xcode_plugin.rb,
lib/fastlane/actions/set_info_plist_value.rb,
lib/fastlane/actions/version_bump_podspec.rb,
lib/fastlane/actions/clean_build_artifacts.rb,
lib/fastlane/actions/clean_cocoapods_cache.rb,
lib/fastlane/actions/update_app_identifier.rb,
lib/fastlane/actions/hg_commit_version_bump.rb,
lib/fastlane/actions/hg_ensure_clean_status.rb,
lib/fastlane/actions/increment_build_number.rb,
lib/fastlane/actions/ensure_git_status_clean.rb,
lib/fastlane/actions/xcode_server_get_assets.rb,
lib/fastlane/actions/get_ipa_info_plist_value.rb,
lib/fastlane/actions/increment_version_number.rb,
lib/fastlane/actions/upload_symbols_to_sentry.rb,
lib/fastlane/actions/changelog_from_git_commits.rb,
lib/fastlane/actions/get_build_number_repository.rb,
lib/fastlane/actions/make_changelog_from_jenkins.rb,
lib/fastlane/actions/set_build_number_repository.rb,
lib/fastlane/actions/update_project_code_signing.rb,
lib/fastlane/actions/update_project_provisioning.rb,
lib/fastlane/actions/update_app_group_identifiers.rb,
lib/fastlane/actions/upload_symbols_to_crashlytics.rb,
lib/fastlane/actions/latest_testflight_build_number.rb,
lib/fastlane/actions/update_icloud_container_identifiers.rb

Defined Under Namespace

Modules: SharedValues Classes: AdbAction, AdbDevicesAction, AddGitTagAction, AppaloosaAction, AppetizeAction, AppiumAction, AppledocAction, AppstoreAction, ArtifactoryAction, BackupFileAction, BackupXcarchiveAction, BadgeAction, BundleInstallAction, CarthageAction, CertAction, ChangelogFromGitCommitsAction, ChatworkAction, CleanBuildArtifactsAction, CleanCocoapodsCacheAction, ClearDerivedDataAction, ClipboardAction, ClocAction, CocoapodsAction, CommitVersionBumpAction, CopyArtifactsAction, CrashlyticsAction, CreateKeychainAction, CreatePullRequestAction, DebugAction, DefaultPlatformAction, DeleteKeychainAction, DeliverAction, DeploygateAction, DotgpgEnvironmentAction, DownloadAction, DownloadDsymsAction, DsymZipAction, EnsureGitBranchAction, EnsureGitStatusCleanAction, EnsureNoDebugCodeAction, EnsureXcodeVersionAction, ErbAction, FastlaneVersionAction, FrameitAction, GcovrAction, GetBuildNumberAction, GetBuildNumberRepositoryAction, GetGithubReleaseAction, GetInfoPlistValueAction, GetIpaInfoPlistValueAction, GetVersionNumberAction, GitAddAction, GitBranchAction, GitCommitAction, GitPullAction, GradleAction, GymAction, HgAddTagAction, HgCommitVersionBumpAction, HgEnsureCleanStatusAction, HgPushAction, HipchatAction, HockeyAction, IftttAction, ImportAction, ImportCertificateAction, ImportFromGitAction, IncrementBuildNumberAction, IncrementVersionNumberAction, InstallOnDeviceAction, InstallXcodePluginAction, InstallrAction, IpaAction, IsCiAction, JazzyAction, LaneContextAction, LastGitCommitAction, LastGitTagAction, LatestTestflightBuildNumberAction, LcovAction, MailgunAction, MakeChangelogFromJenkinsAction, MatchAction, NexusUploadAction, NotificationAction, NotifyAction, NumberOfCommitsAction, OclintAction, OnesignalAction, OptOutUsageAction, PemAction, PilotAction, PodPushAction, PodioItemAction, ProduceAction, PromptAction, PushGitTagsAction, PushToGitRemoteAction, PutsAction, ReadPodspecAction, RecreateSchemesAction, RegisterDevicesAction, ResetGitRepoAction, ResetSimulatorsAction, ResignAction, RestoreFileAction, RocketAction, RsyncAction, S3Action, SayAction, ScanAction, ScpAction, ScreengrabAction, SetBuildNumberRepositoryAction, SetChangelogAction, SetGithubReleaseAction, SetInfoPlistValueAction, SetupJenkinsAction, SighAction, SkipDocsAction, SlackAction, SlatherAction, SnapshotAction, SonarAction, SplunkmintAction, SshAction, SupplyAction, SwiftlintAction, TeamIdAction, TeamNameAction, TestfairyAction, TestflightAction, TestmunkAction, TryoutsAction, TwitterAction, TypetalkAction, UnlockKeychainAction, UpdateAppGroupIdentifiersAction, UpdateAppIdentifierAction, UpdateFastlaneAction, UpdateIcloudContainerIdentifiersAction, UpdateInfoPlistAction, UpdateProjectCodeSigningAction, UpdateProjectProvisioningAction, UpdateProjectTeamAction, UpdateUrlSchemesAction, UploadSymbolsToCrashlyticsAction, UploadSymbolsToSentryAction, VerifyBuildAction, VerifyPodKeysAction, VerifyXcodeAction, VersionBumpPodspecAction, VersionGetPodspecAction, XcakeAction, XcarchiveAction, XcbuildAction, XccleanAction, XcexportAction, XcodeInstallAction, XcodeSelectAction, XcodeServerGetAssetsAction, XcodebuildAction, XcovAction, XctestAction, XctoolAction, ZipAction

Constant Summary collapse

S3_ARGS_MAP =
{
  ipa: '-f',
  dsym: '-d',
  access_key: '-a',
  secret_access_key: '-s',
  bucket: '-b',
  region: '-r',
  acl: '--acl',
  source: '--source-dir',
  path: '-P'
}
ARGS_MAP =
{
  workspace: '-w',
  project: '-p',
  configuration: '-c',
  scheme: '-s',
  clean: '--clean',
  archive: '--archive',
  destination: '-d',
  embed: '-m',
  identity: '-i',
  sdk: '--sdk',
  ipa: '--ipa',
  xcconfig: '--xcconfig',
  xcargs: '--xcargs'
}
GIT_MERGE_COMMIT_FILTERING_OPTIONS =
[:include_merges, :exclude_merges, :only_include_merges].freeze

Class Method Summary collapse

Class Method Details

.clear_lane_contextObject

Used in tests to get a clear lane before every test



19
20
21
# File 'lib/fastlane/actions/actions_helper.rb', line 19

def self.clear_lane_context
  @lane_context = nil
end

.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, …) This might be nil, in which case the step is not printed out to the terminal



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fastlane/actions/actions_helper.rb', line 26

def self.execute_action(step_name)
  start = Time.now # before the raise block, since `start` is required in the ensure block
  UI.crash!("No block given") unless block_given?

  error = nil
  exc = nil

  begin
    UI.header("Step: " + step_name) if step_name
    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
  if step_name
    duration = Time.now - start

    executed_actions << {
      name: step_name,
      error: error,
      time: duration
    }
  end

  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

.get_all_official_actionsObject

returns a list of official integrations rubocop:disable Style/AccessorMethodName



57
58
59
60
61
# File 'lib/fastlane/actions/actions_helper.rb', line 57

def self.get_all_official_actions
  Dir[File.expand_path('*.rb', File.dirname(__FILE__))].collect do |file|
    File.basename(file).gsub('.rb', '').to_sym
  end
end

.git_authorObject

Deprecated.

Use git_author_email instead

Get the author email of the last git commit DEPRECATED: Use git_author_email instead.



48
49
50
51
# File 'lib/fastlane/helper/git_helper.rb', line 48

def self.git_author
  UI.deprecated('`git_author` is deprecated. Please use `git_author_email` instead.')
  git_author_email
end

.git_author_emailObject

Get the author email of the last git commit



54
55
56
57
58
# File 'lib/fastlane/helper/git_helper.rb', line 54

def self.git_author_email
  s = last_git_commit_formatted_with('%ae')
  return s if s.to_s.length > 0
  return nil
end

.git_branchObject

Returns the current git branch - can be replaced using the environment variable ‘GIT_BRANCH`



75
76
77
78
79
80
81
82
# File 'lib/fastlane/helper/git_helper.rb', line 75

def self.git_branch
  return ENV['GIT_BRANCH'] if ENV['GIT_BRANCH'].to_s.length > 0 # set by Jenkins
  s = Actions.sh("git rev-parse --abbrev-ref HEAD", log: false).chomp
  return s.to_s.strip if s.to_s.length > 0
  nil
rescue
  nil
end

.git_log_between(pretty_format, from, to, merge_commit_filtering) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/fastlane/helper/git_helper.rb', line 5

def self.git_log_between(pretty_format, from, to, merge_commit_filtering)
  command = 'git log'
  command << " --pretty=\"#{pretty_format}\" #{from.shellescape}...#{to.shellescape}"
  command << " --no-merges" if merge_commit_filtering == :exclude_merges
  command << " --merges" if merge_commit_filtering == :only_include_merges
  Actions.sh(command, log: false).chomp
rescue
  nil
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

.last_git_commitObject

Returns the unwrapped subject and body of the last commit DEPRECATED: Use last_git_commit_message instead.



62
63
64
65
# File 'lib/fastlane/helper/git_helper.rb', line 62

def self.last_git_commit
  UI.important('`last_git_commit` is deprecated. Please use `last_git_commit_message` instead.')
  last_git_commit_message
end

.last_git_commit_dictObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/fastlane/helper/git_helper.rb', line 26

def self.last_git_commit_dict
  return nil if last_git_commit_formatted_with('%an').nil?

  {
      author: last_git_commit_formatted_with('%an'),
      message: last_git_commit_formatted_with('%B'),
      commit_hash: last_git_commit_formatted_with('%H'),
      abbreviated_commit_hash: last_git_commit_formatted_with('%h')
  }
end

.last_git_commit_formatted_with(pretty_format) ⇒ Object

Gets the last git commit information formatted into a String by the provided pretty format String. See the git-log documentation for valid format placeholders



39
40
41
42
43
# File 'lib/fastlane/helper/git_helper.rb', line 39

def self.last_git_commit_formatted_with(pretty_format)
  Actions.sh("git log -1 --pretty=#{pretty_format}", log: false).chomp
rescue
  nil
end

.last_git_commit_messageObject

Returns the unwrapped subject and body of the last commit



68
69
70
71
72
# File 'lib/fastlane/helper/git_helper.rb', line 68

def self.last_git_commit_message
  s = (last_git_commit_formatted_with('%B') || "").strip
  return s if s.to_s.length > 0
  nil
end

.last_git_tag_name(match_lightweight = true, tag_match_pattern = nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fastlane/helper/git_helper.rb', line 15

def self.last_git_tag_name(match_lightweight = true, tag_match_pattern = nil)
  tag_pattern_param = tag_match_pattern ? "=#{tag_match_pattern.shellescape}" : ''

  command = ['git describe']
  command << '--tags' if match_lightweight
  command << "`git rev-list --tags#{tag_pattern_param} --max-count=1`"
  Actions.sh(command.join(' '), log: false).chomp
rescue
  nil
end

.load_default_actionsObject

rubocop:enable Style/AccessorMethodName



64
65
66
67
68
# File 'lib/fastlane/actions/actions_helper.rb', line 64

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



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/fastlane/actions/actions_helper.rb', line 77

def self.load_external_actions(path)
  UI.user_error!("You need to pass a valid path") unless File.exist?(path)

  Dir[File.expand_path('*.rb', path)].each do |file|
    require file

    file_name = File.basename(file).gsub('.rb', '')

    class_name = file_name.fastlane_class + 'Action'
    begin
      class_ref = Fastlane::Actions.const_get(class_name)

      if class_ref.respond_to?(:run)
        UI.success "Successfully loaded custom action '#{file}'."
      else
        UI.error "Could not find method 'run' in class #{class_name}."
        UI.error 'For more information, check out the docs: https://github.com/fastlane/fastlane/tree/master/fastlane'
        UI.user_error!("Action '#{file_name}' is damaged!")
      end
    rescue NameError
      # Action not found
      UI.error "Could not find '#{class_name}' class defined."
      UI.error 'For more information, check out the docs: https://github.com/fastlane/fastlane/tree/master/fastlane'
      UI.user_error!("Action '#{file_name}' is damaged!")
    end
  end
end

.load_helpersObject

Import all the helpers



71
72
73
74
75
# File 'lib/fastlane/actions/actions_helper.rb', line 71

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

.sh(command, log: true) ⇒ Object

Execute a shell command This method will output the string and execute it Just an alias for sh_no_action When running this in tests, it will return the actual command instead of executing it

Parameters:

  • log (boolean) (defaults to: true)

    should fastlane print out the executed command



8
9
10
# File 'lib/fastlane/helper/sh_helper.rb', line 8

def self.sh(command, log: true)
  sh_no_action(command, log: log)
end

.sh_no_action(command, log: true) ⇒ 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/fastlane/helper/sh_helper.rb', line 12

def self.sh_no_action(command, log: true)
  # Set the encoding first, the user might have set it wrong
  previous_encoding = [Encoding.default_external, Encoding.default_internal]
  Encoding.default_external = Encoding::UTF_8
  Encoding.default_internal = Encoding::UTF_8

  command = command.join(' ') if command.kind_of?(Array) # since it's an array of one element when running from the Fastfile
  UI.command(command) if log

  result = ''
  if Helper.test?
    result << command # only for the tests
  else
    exit_status = nil
    IO.popen(command, err: [:child, :out]) do |io|
      io.sync = true
      io.each do |line|
        UI.command_output(line.strip) if log
        result << line
      end
      io.close
      exit_status = $?.exitstatus
    end

    if exit_status != 0
      # this will also append the output to the exception
      if log
        message = "Exit status of command '#{command}' was #{exit_status} instead of 0."
        message += "\n#{result}"
      else
        message = "Shell command exited with exit status #{exit_status} instead of 0."
      end
      UI.crash!(message)
    end
  end

  result
rescue => ex
  raise ex
ensure
  Encoding.default_external = previous_encoding.first
  Encoding.default_internal = previous_encoding.last
end

.verify_gem!(gem_name) ⇒ Object

will make sure a gem is installed. If it’s not an appropriate error message is shown this will not ‘require’ the gem



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fastlane/helper/gem_helper.rb', line 5

def self.verify_gem!(gem_name)
  begin
    Gem::Specification.find_by_name(gem_name)
    # We don't import this by default, as it's not always the same
    # also e.g. cocoapods is just required and not imported
  rescue Gem::LoadError
    UI.error("Could not find gem '#{gem_name}'")
    UI.error("")
    UI.error("If you installed fastlane using `sudo gem install fastlane` run")
    UI.command("sudo gem install #{gem_name}")
    UI.error("to install the missing gem")
    UI.error("")
    UI.error("If you use a Gemfile add this to your Gemfile:")
    UI.important("  gem '#{gem_name}'")
    UI.error("and run `bundle install`")

    UI.user_error!("You have to install the `#{gem_name}` gem on this machine") unless Helper.is_test?
  end
  true
end