Module: Fastlane::Actions

Defined in:
fastlane/lib/fastlane/actions/s3.rb,
fastlane/lib/fastlane/actions/sh.rb,
fastlane/lib/fastlane/actions/adb.rb,
fastlane/lib/fastlane/actions/erb.rb,
fastlane/lib/fastlane/actions/gym.rb,
fastlane/lib/fastlane/actions/ipa.rb,
fastlane/lib/fastlane/actions/pem.rb,
fastlane/lib/fastlane/actions/say.rb,
fastlane/lib/fastlane/actions/scp.rb,
fastlane/lib/fastlane/actions/spm.rb,
fastlane/lib/fastlane/actions/ssh.rb,
fastlane/lib/fastlane/actions/zip.rb,
fastlane/lib/fastlane/actions/cert.rb,
fastlane/lib/fastlane/actions/cloc.rb,
fastlane/lib/fastlane/actions/echo.rb,
fastlane/lib/fastlane/actions/jira.rb,
fastlane/lib/fastlane/actions/lcov.rb,
fastlane/lib/fastlane/actions/puts.rb,
fastlane/lib/fastlane/actions/scan.rb,
fastlane/lib/fastlane/actions/sigh.rb,
fastlane/lib/fastlane/actions/xcov.rb,
fastlane/lib/fastlane/actions/badge.rb,
fastlane/lib/fastlane/actions/debug.rb,
fastlane/lib/fastlane/actions/flock.rb,
fastlane/lib/fastlane/actions/gcovr.rb,
fastlane/lib/fastlane/actions/ifttt.rb,
fastlane/lib/fastlane/actions/is_ci.rb,
fastlane/lib/fastlane/actions/jazzy.rb,
fastlane/lib/fastlane/actions/match.rb,
fastlane/lib/fastlane/actions/pilot.rb,
fastlane/lib/fastlane/actions/rsync.rb,
fastlane/lib/fastlane/actions/slack.rb,
fastlane/lib/fastlane/actions/sonar.rb,
fastlane/lib/fastlane/actions/appium.rb,
fastlane/lib/fastlane/actions/danger.rb,
fastlane/lib/fastlane/actions/gradle.rb,
fastlane/lib/fastlane/actions/hockey.rb,
fastlane/lib/fastlane/actions/import.rb,
fastlane/lib/fastlane/actions/notify.rb,
fastlane/lib/fastlane/actions/oclint.rb,
fastlane/lib/fastlane/actions/prompt.rb,
fastlane/lib/fastlane/actions/resign.rb,
fastlane/lib/fastlane/actions/rocket.rb,
fastlane/lib/fastlane/actions/supply.rb,
fastlane/lib/fastlane/actions/xctool.rb,
fastlane/lib/fastlane/actions/deliver.rb,
fastlane/lib/fastlane/actions/frameit.rb,
fastlane/lib/fastlane/actions/git_add.rb,
fastlane/lib/fastlane/actions/hg_push.rb,
fastlane/lib/fastlane/actions/hipchat.rb,
fastlane/lib/fastlane/actions/mailgun.rb,
fastlane/lib/fastlane/actions/println.rb,
fastlane/lib/fastlane/actions/produce.rb,
fastlane/lib/fastlane/actions/slather.rb,
fastlane/lib/fastlane/actions/team_id.rb,
fastlane/lib/fastlane/actions/tryouts.rb,
fastlane/lib/fastlane/actions/twitter.rb,
fastlane/lib/fastlane/actions/appetize.rb,
fastlane/lib/fastlane/actions/appledoc.rb,
fastlane/lib/fastlane/actions/appstore.rb,
fastlane/lib/fastlane/actions/carthage.rb,
fastlane/lib/fastlane/actions/chatwork.rb,
fastlane/lib/fastlane/actions/download.rb,
fastlane/lib/fastlane/actions/dsym_zip.rb,
fastlane/lib/fastlane/actions/git_pull.rb,
fastlane/lib/fastlane/actions/installr.rb,
fastlane/lib/fastlane/actions/pod_push.rb,
fastlane/lib/fastlane/actions/precheck.rb,
fastlane/lib/fastlane/actions/setup_ci.rb,
fastlane/lib/fastlane/actions/snapshot.rb,
fastlane/lib/fastlane/actions/typetalk.rb,
fastlane/lib/fastlane/helper/sh_helper.rb,
fastlane/lib/fastlane/actions/appaloosa.rb,
fastlane/lib/fastlane/actions/build_app.rb,
fastlane/lib/fastlane/actions/clipboard.rb,
fastlane/lib/fastlane/actions/cocoapods.rb,
fastlane/lib/fastlane/actions/onesignal.rb,
fastlane/lib/fastlane/actions/run_tests.rb,
fastlane/lib/fastlane/actions/skip_docs.rb,
fastlane/lib/fastlane/actions/swiftlint.rb,
fastlane/lib/fastlane/actions/team_name.rb,
fastlane/lib/fastlane/actions/testfairy.rb,
fastlane/lib/fastlane/actions/xcversion.rb,
fastlane/lib/fastlane/helper/gem_helper.rb,
fastlane/lib/fastlane/helper/git_helper.rb,
fastlane/lib/fastlane/actions/apteligent.rb,
fastlane/lib/fastlane/actions/deploygate.rb,
fastlane/lib/fastlane/actions/git_branch.rb,
fastlane/lib/fastlane/actions/git_commit.rb,
fastlane/lib/fastlane/actions/github_api.rb,
fastlane/lib/fastlane/actions/hg_add_tag.rb,
fastlane/lib/fastlane/actions/podio_item.rb,
fastlane/lib/fastlane/actions/screengrab.rb,
fastlane/lib/fastlane/actions/splunkmint.rb,
fastlane/lib/fastlane/actions/testflight.rb,
fastlane/lib/fastlane/actions/xcodebuild.rb,
fastlane/lib/fastlane/actions/adb_devices.rb,
fastlane/lib/fastlane/actions/add_git_tag.rb,
fastlane/lib/fastlane/actions/artifactory.rb,
fastlane/lib/fastlane/actions/backup_file.rb,
fastlane/lib/fastlane/actions/crashlytics.rb,
fastlane/lib/fastlane/actions/set_pod_key.rb,
fastlane/lib/fastlane/actions/lane_context.rb,
fastlane/lib/fastlane/actions/last_git_tag.rb,
fastlane/lib/fastlane/actions/nexus_upload.rb,
fastlane/lib/fastlane/actions/notification.rb,
fastlane/lib/fastlane/actions/pod_lib_lint.rb,
fastlane/lib/fastlane/actions/read_podspec.rb,
fastlane/lib/fastlane/actions/restore_file.rb,
fastlane/lib/fastlane/actions/ruby_version.rb,
fastlane/lib/fastlane/actions/setup_travis.rb,
fastlane/lib/fastlane/actions/update_plist.rb,
fastlane/lib/fastlane/actions/verify_build.rb,
fastlane/lib/fastlane/actions/verify_xcode.rb,
fastlane/lib/fastlane/actions/xcode_select.rb,
fastlane/lib/fastlane/actions/build_ios_app.rb,
fastlane/lib/fastlane/actions/build_mac_app.rb,
fastlane/lib/fastlane/actions/opt_out_usage.rb,
fastlane/lib/fastlane/actions/push_git_tags.rb,
fastlane/lib/fastlane/actions/set_changelog.rb,
fastlane/lib/fastlane/actions/setup_jenkins.rb,
fastlane/lib/fastlane/actions/xcode_install.rb,
fastlane/lib/fastlane/actions/actions_helper.rb,
fastlane/lib/fastlane/actions/bundle_install.rb,
fastlane/lib/fastlane/actions/copy_artifacts.rb,
fastlane/lib/fastlane/actions/download_dsyms.rb,
fastlane/lib/fastlane/actions/git_tag_exists.rb,
fastlane/lib/fastlane/actions/reset_git_repo.rb,
fastlane/lib/fastlane/actions/spaceship_logs.rb,
fastlane/lib/fastlane/actions/create_keychain.rb,
fastlane/lib/fastlane/actions/delete_keychain.rb,
fastlane/lib/fastlane/actions/ensure_env_vars.rb,
fastlane/lib/fastlane/actions/import_from_git.rb,
fastlane/lib/fastlane/actions/last_git_commit.rb,
fastlane/lib/fastlane/actions/modify_services.rb,
fastlane/lib/fastlane/actions/register_device.rb,
fastlane/lib/fastlane/actions/setup_circle_ci.rb,
fastlane/lib/fastlane/actions/unlock_keychain.rb,
fastlane/lib/fastlane/actions/update_fastlane.rb,
fastlane/lib/fastlane/actions/verify_pod_keys.rb,
fastlane/lib/fastlane/actions/backup_xcarchive.rb,
fastlane/lib/fastlane/actions/default_platform.rb,
fastlane/lib/fastlane/actions/fastlane_version.rb,
fastlane/lib/fastlane/actions/get_build_number.rb,
fastlane/lib/fastlane/actions/get_certificates.rb,
fastlane/lib/fastlane/actions/recreate_schemes.rb,
fastlane/lib/fastlane/actions/register_devices.rb,
fastlane/lib/fastlane/actions/build_android_app.rb,
fastlane/lib/fastlane/actions/create_app_online.rb,
fastlane/lib/fastlane/actions/ensure_git_branch.rb,
fastlane/lib/fastlane/actions/frame_screenshots.rb,
fastlane/lib/fastlane/actions/install_on_device.rb,
fastlane/lib/fastlane/actions/number_of_commits.rb,
fastlane/lib/fastlane/actions/sync_code_signing.rb,
fastlane/lib/fastlane/actions/update_info_plist.rb,
fastlane/lib/fastlane/actions/clear_derived_data.rb,
fastlane/lib/fastlane/actions/commit_github_file.rb,
fastlane/lib/fastlane/actions/dotgpg_environment.rb,
fastlane/lib/fastlane/actions/ensure_bundle_exec.rb,
fastlane/lib/fastlane/actions/get_github_release.rb,
fastlane/lib/fastlane/actions/get_version_number.rb,
fastlane/lib/fastlane/actions/import_certificate.rb,
fastlane/lib/fastlane/actions/push_to_git_remote.rb,
fastlane/lib/fastlane/actions/set_github_release.rb,
fastlane/lib/fastlane/actions/update_url_schemes.rb,
fastlane/lib/fastlane/actions/add_extra_platforms.rb,
fastlane/lib/fastlane/actions/capture_screenshots.rb,
fastlane/lib/fastlane/actions/commit_version_bump.rb,
fastlane/lib/fastlane/actions/create_pull_request.rb,
fastlane/lib/fastlane/actions/update_project_team.rb,
fastlane/lib/fastlane/actions/upload_to_app_store.rb,
fastlane/lib/fastlane/actions/version_get_podspec.rb,
fastlane/lib/fastlane/actions/ensure_no_debug_code.rb,
fastlane/lib/fastlane/actions/ensure_xcode_version.rb,
fastlane/lib/fastlane/actions/environment_variable.rb,
fastlane/lib/fastlane/actions/get_info_plist_value.rb,
fastlane/lib/fastlane/actions/get_push_certificate.rb,
fastlane/lib/fastlane/actions/git_submodule_update.rb,
fastlane/lib/fastlane/actions/install_xcode_plugin.rb,
fastlane/lib/fastlane/actions/min_fastlane_version.rb,
fastlane/lib/fastlane/actions/set_info_plist_value.rb,
fastlane/lib/fastlane/actions/upload_to_play_store.rb,
fastlane/lib/fastlane/actions/upload_to_testflight.rb,
fastlane/lib/fastlane/actions/version_bump_podspec.rb,
fastlane/lib/fastlane/actions/clean_build_artifacts.rb,
fastlane/lib/fastlane/actions/clean_cocoapods_cache.rb,
fastlane/lib/fastlane/actions/update_app_identifier.rb,
fastlane/lib/fastlane/actions/app_store_build_number.rb,
fastlane/lib/fastlane/actions/automatic_code_signing.rb,
fastlane/lib/fastlane/actions/hg_commit_version_bump.rb,
fastlane/lib/fastlane/actions/hg_ensure_clean_status.rb,
fastlane/lib/fastlane/actions/increment_build_number.rb,
fastlane/lib/fastlane/actions/capture_ios_screenshots.rb,
fastlane/lib/fastlane/actions/ensure_git_status_clean.rb,
fastlane/lib/fastlane/actions/opt_out_crash_reporting.rb,
fastlane/lib/fastlane/actions/xcode_server_get_assets.rb,
fastlane/lib/fastlane/actions/check_app_store_metadata.rb,
fastlane/lib/fastlane/actions/download_from_play_store.rb,
fastlane/lib/fastlane/actions/get_ipa_info_plist_value.rb,
fastlane/lib/fastlane/actions/get_provisioning_profile.rb,
fastlane/lib/fastlane/actions/increment_version_number.rb,
fastlane/lib/fastlane/actions/reset_simulator_contents.rb,
fastlane/lib/fastlane/actions/upload_symbols_to_sentry.rb,
fastlane/lib/fastlane/actions/changelog_from_git_commits.rb,
fastlane/lib/fastlane/actions/capture_android_screenshots.rb,
fastlane/lib/fastlane/actions/get_build_number_repository.rb,
fastlane/lib/fastlane/actions/make_changelog_from_jenkins.rb,
fastlane/lib/fastlane/actions/set_build_number_repository.rb,
fastlane/lib/fastlane/actions/update_project_code_signing.rb,
fastlane/lib/fastlane/actions/update_project_provisioning.rb,
fastlane/lib/fastlane/actions/build_and_upload_to_appetize.rb,
fastlane/lib/fastlane/actions/install_provisioning_profile.rb,
fastlane/lib/fastlane/actions/update_app_group_identifiers.rb,
fastlane/lib/fastlane/actions/validate_play_store_json_key.rb,
fastlane/lib/fastlane/actions/update_keychain_access_groups.rb,
fastlane/lib/fastlane/actions/upload_symbols_to_crashlytics.rb,
fastlane/lib/fastlane/actions/appetize_viewing_url_generator.rb,
fastlane/lib/fastlane/actions/latest_testflight_build_number.rb,
fastlane/lib/fastlane/actions/google_play_track_version_codes.rb,
fastlane/lib/fastlane/actions/create_app_on_managed_play_store.rb,
fastlane/lib/fastlane/actions/update_urban_airship_configuration.rb,
fastlane/lib/fastlane/actions/update_icloud_container_identifiers.rb,
fastlane/lib/fastlane/actions/get_managed_play_store_publishing_rights.rb,
fastlane/lib/fastlane/actions/upload_to_play_store_internal_app_sharing.rb

Defined Under Namespace

Modules: SharedValues Classes: AdbAction, AdbDevicesAction, AddExtraPlatformsAction, AddGitTagAction, AppStoreBuildNumberAction, AppaloosaAction, AppetizeAction, AppetizeViewingUrlGeneratorAction, AppiumAction, AppledocAction, AppstoreAction, ApteligentAction, ArtifactoryAction, AutomaticCodeSigningAction, BackupFileAction, BackupXcarchiveAction, BadgeAction, BuildAndUploadToAppetizeAction, BuildAndroidAppAction, BuildAppAction, BuildIosAppAction, BuildMacAppAction, BundleInstallAction, CaptureAndroidScreenshotsAction, CaptureIosScreenshotsAction, CaptureScreenshotsAction, CarthageAction, CertAction, ChangelogFromGitCommitsAction, ChatworkAction, CheckAppStoreMetadataAction, CleanBuildArtifactsAction, CleanCocoapodsCacheAction, ClearDerivedDataAction, ClipboardAction, ClocAction, CocoapodsAction, CommitGithubFileAction, CommitVersionBumpAction, CopyArtifactsAction, CrashlyticsAction, CreateAppOnManagedPlayStoreAction, CreateAppOnlineAction, CreateKeychainAction, CreatePullRequestAction, DangerAction, DebugAction, DefaultPlatformAction, DeleteKeychainAction, DeliverAction, DeploygateAction, DotgpgEnvironmentAction, DownloadAction, DownloadDsymsAction, DownloadFromPlayStoreAction, DsymZipAction, EchoAction, EnsureBundleExecAction, EnsureEnvVarsAction, EnsureGitBranchAction, EnsureGitStatusCleanAction, EnsureNoDebugCodeAction, EnsureXcodeVersionAction, EnvironmentVariableAction, ErbAction, FastlaneVersionAction, FlockAction, FrameScreenshotsAction, FrameitAction, GcovrAction, GetBuildNumberAction, GetBuildNumberRepositoryAction, GetCertificatesAction, GetGithubReleaseAction, GetInfoPlistValueAction, GetIpaInfoPlistValueAction, GetManagedPlayStorePublishingRightsAction, GetProvisioningProfileAction, GetPushCertificateAction, GetVersionNumberAction, GitAddAction, GitBranchAction, GitCommitAction, GitPullAction, GitSubmoduleUpdateAction, GitTagExistsAction, GithubApiAction, GooglePlayTrackVersionCodesAction, GradleAction, GymAction, HgAddTagAction, HgCommitVersionBumpAction, HgEnsureCleanStatusAction, HgPushAction, HipchatAction, HockeyAction, IftttAction, ImportAction, ImportCertificateAction, ImportFromGitAction, IncrementBuildNumberAction, IncrementVersionNumberAction, InstallOnDeviceAction, InstallProvisioningProfileAction, InstallXcodePluginAction, InstallrAction, IpaAction, IsCiAction, JazzyAction, JiraAction, LaneContextAction, LastGitCommitAction, LastGitTagAction, LatestTestflightBuildNumberAction, LcovAction, MailgunAction, MakeChangelogFromJenkinsAction, MatchAction, MinFastlaneVersionAction, ModifyServicesAction, NexusUploadAction, NotificationAction, NotifyAction, NumberOfCommitsAction, OclintAction, OnesignalAction, OptOutCrashReportingAction, OptOutUsageAction, PemAction, PilotAction, PodLibLintAction, PodPushAction, PodioItemAction, PrecheckAction, PrintlnAction, ProduceAction, PromptAction, PushGitTagsAction, PushToGitRemoteAction, PutsAction, ReadPodspecAction, RecreateSchemesAction, RegisterDeviceAction, RegisterDevicesAction, ResetGitRepoAction, ResetSimulatorContentsAction, ResignAction, RestoreFileAction, RocketAction, RsyncAction, RubyVersionAction, RunTestsAction, S3Action, SayAction, ScanAction, ScpAction, ScreengrabAction, SetBuildNumberRepositoryAction, SetChangelogAction, SetGithubReleaseAction, SetInfoPlistValueAction, SetPodKeyAction, SetupCiAction, SetupCircleCiAction, SetupJenkinsAction, SetupTravisAction, ShAction, SighAction, SkipDocsAction, SlackAction, SlatherAction, SnapshotAction, SonarAction, SpaceshipLogsAction, SplunkmintAction, SpmAction, SshAction, SupplyAction, SwiftlintAction, SyncCodeSigningAction, TeamIdAction, TeamNameAction, TestfairyAction, TestflightAction, TryoutsAction, TwitterAction, TypetalkAction, UnlockKeychainAction, UpdateAppGroupIdentifiersAction, UpdateAppIdentifierAction, UpdateFastlaneAction, UpdateIcloudContainerIdentifiersAction, UpdateInfoPlistAction, UpdateKeychainAccessGroupsAction, UpdatePlistAction, UpdateProjectCodeSigningAction, UpdateProjectProvisioningAction, UpdateProjectTeamAction, UpdateUrbanAirshipConfigurationAction, UpdateUrlSchemesAction, UploadSymbolsToCrashlyticsAction, UploadSymbolsToSentryAction, UploadToAppStoreAction, UploadToPlayStoreAction, UploadToPlayStoreInternalAppSharingAction, UploadToTestflightAction, ValidatePlayStoreJsonKeyAction, VerifyBuildAction, VerifyPodKeysAction, VerifyXcodeAction, VersionBumpPodspecAction, VersionGetPodspecAction, XcarchiveAction, XcbuildAction, XccleanAction, XcexportAction, XcodeInstallAction, XcodeSelectAction, XcodeServerGetAssetsAction, XcodebuildAction, XcovAction, XctestAction, XctoolAction, XcversionAction, 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

.action_class_ref(action_name) ⇒ Object

Returns the class ref to the action based on the action name Returns nil if the action is not available



81
82
83
84
85
86
87
88
89
90
# File 'fastlane/lib/fastlane/actions/actions_helper.rb', line 81

def self.action_class_ref(action_name)
  class_name = action_name.to_s.fastlane_class + 'Action'
  class_ref = nil
  begin
    class_ref = Fastlane::Actions.const_get(class_name)
  rescue NameError
    return nil
  end
  return class_ref
end

.add_modified_files(files) ⇒ Object

Add an array of paths relative to the repo root or absolute paths that have been modified by an action.

:files: An array of paths relative to the repo root or absolute paths



14
15
16
17
18
# File 'fastlane/lib/fastlane/actions/commit_version_bump.rb', line 14

def add_modified_files(files)
  modified_files = lane_context[SharedValues::MODIFIED_FILES] || Set.new
  modified_files += files
  lane_context[SharedValues::MODIFIED_FILES] = modified_files
end

.alias_actionsObject



13
14
15
16
17
18
19
20
21
22
# File 'fastlane/lib/fastlane/actions/actions_helper.rb', line 13

def self.alias_actions
  unless @alias_actions
    @alias_actions = {}
    ActionsList.all_actions do |action, name|
      next unless action.respond_to?(:aliases)
      @alias_actions[name] = action.aliases
    end
  end
  @alias_actions
end

.clear_lane_contextObject

Used in tests to get a clear lane before every test



34
35
36
# File 'fastlane/lib/fastlane/actions/actions_helper.rb', line 34

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



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'fastlane/lib/fastlane/actions/actions_helper.rb', line 41

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



24
25
26
# File 'fastlane/lib/fastlane/actions/actions_helper.rb', line 24

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

.formerly_bundled_actionsObject



148
149
150
# File 'fastlane/lib/fastlane/actions/actions_helper.rb', line 148

def self.formerly_bundled_actions
  ["xcake"]
end

.get_all_official_actionsObject

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



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

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.



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

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



85
86
87
88
89
# File 'fastlane/lib/fastlane/helper/git_helper.rb', line 85

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`



114
115
116
117
118
119
120
121
# File 'fastlane/lib/fastlane/helper/git_helper.rb', line 114

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, date_format = nil, ancestry_path) ⇒ Object



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

def self.git_log_between(pretty_format, from, to, merge_commit_filtering, date_format = nil, ancestry_path)
  command = %w(git log)
  command << "--pretty=#{pretty_format}"
  command << "--date=#{date_format}" if date_format
  command << '--ancestry-path' if ancestry_path
  command << "#{from}...#{to}"
  command << git_log_merge_commit_filtering_option(merge_commit_filtering)
  # "*command" syntax expands "command" array into variable arguments, which
  # will then be individually shell-escaped by Actions.sh.
  Actions.sh(*command.compact, log: false).chomp
rescue
  nil
end

.git_log_last_commits(pretty_format, commit_count, merge_commit_filtering, date_format = nil, ancestry_path) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'fastlane/lib/fastlane/helper/git_helper.rb', line 19

def self.git_log_last_commits(pretty_format, commit_count, merge_commit_filtering, date_format = nil, ancestry_path)
  command = %w(git log)
  command << "--pretty=#{pretty_format}"
  command << "--date=#{date_format}" if date_format
  command << '--ancestry-path' if ancestry_path
  command << '-n' << commit_count.to_s
  command << git_log_merge_commit_filtering_option(merge_commit_filtering)
  Actions.sh(*command.compact, log: false).chomp
rescue
  nil
end

.git_log_merge_commit_filtering_option(merge_commit_filtering) ⇒ Object



124
125
126
127
128
129
130
131
132
133
# File 'fastlane/lib/fastlane/helper/git_helper.rb', line 124

def self.git_log_merge_commit_filtering_option(merge_commit_filtering)
  case merge_commit_filtering
  when :exclude_merges
    "--no-merges"
  when :only_include_merges
    "--merges"
  when :include_merges
    nil
  end
end

.is_class_action?(class_ref) ⇒ Boolean

Returns a boolean indicating whether the class reference is a Fastlane::Action

Returns:



154
155
156
157
158
# File 'fastlane/lib/fastlane/actions/actions_helper.rb', line 154

def self.is_class_action?(class_ref)
  return false if class_ref.nil?
  is_an_action = class_ref < Fastlane::Action
  return is_an_action || false
end

.is_deprecated?(class_ref) ⇒ Boolean

Returns a boolean indicating if the class reference is a deprecated Fastlane::Action

Returns:



162
163
164
# File 'fastlane/lib/fastlane/actions/actions_helper.rb', line 162

def self.is_deprecated?(class_ref)
  is_class_action?(class_ref) && class_ref.category == :deprecated
end

.lane_contextObject

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



29
30
31
# File 'fastlane/lib/fastlane/actions/actions_helper.rb', line 29

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.



93
94
95
96
# File 'fastlane/lib/fastlane/helper/git_helper.rb', line 93

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



53
54
55
56
57
58
59
60
61
62
63
# File 'fastlane/lib/fastlane/helper/git_helper.rb', line 53

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

  {
      author: last_git_commit_formatted_with('%an'),
      author_email: last_git_commit_formatted_with('%ae'),
      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, date_format = nil) ⇒ 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



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

def self.last_git_commit_formatted_with(pretty_format, date_format = nil)
  command = %w(git log -1)
  command << "--pretty=#{pretty_format}"
  command << "--date=#{date_format}" if date_format
  Actions.sh(*command.compact, log: false).chomp
rescue
  nil
end

.last_git_commit_hash(short) ⇒ Object

Get the hash of the last commit



106
107
108
109
110
111
# File 'fastlane/lib/fastlane/helper/git_helper.rb', line 106

def self.last_git_commit_hash(short)
  format_specifier = short ? '%h' : '%H'
  string = last_git_commit_formatted_with(format_specifier).to_s
  return string unless string.empty?
  return nil
end

.last_git_commit_messageObject

Returns the unwrapped subject and body of the last commit



99
100
101
102
103
# File 'fastlane/lib/fastlane/helper/git_helper.rb', line 99

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_hash(tag_match_pattern = nil) ⇒ Object



31
32
33
34
35
36
# File 'fastlane/lib/fastlane/helper/git_helper.rb', line 31

def self.last_git_tag_hash(tag_match_pattern = nil)
  tag_pattern_param = tag_match_pattern ? "=#{tag_match_pattern}" : ''
  Actions.sh('git', 'rev-list', "--tags#{tag_pattern_param}", '--max-count=1').chomp
rescue
  nil
end

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



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'fastlane/lib/fastlane/helper/git_helper.rb', line 38

def self.last_git_tag_name(match_lightweight = true, tag_match_pattern = nil)
  hash = last_git_tag_hash(tag_match_pattern)
  # If hash is nil (command fails), "git describe" command below will still
  # run and provide some output, although it's definitely not going to be
  # anything reasonably expected. Bail out early.
  return unless hash

  command = %w(git describe)
  command << '--tags' if match_lightweight
  command << hash
  Actions.sh(*command.compact, log: false).chomp
rescue
  nil
end

.load_default_actionsObject



92
93
94
95
96
# File 'fastlane/lib/fastlane/actions/actions_helper.rb', line 92

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



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'fastlane/lib/fastlane/actions/actions_helper.rb', line 105

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

  class_refs = []
  Dir[File.expand_path('*.rb', path)].each do |file|
    begin
      require file
    rescue SyntaxError => ex
      content = File.read(file, encoding: "utf-8")
      ex.to_s.lines
        .collect { |error| error.match(/#{file}:(\d+):(.*)/) }
        .reject(&:nil?)
        .each { |error| UI.content_error(content, error[1]) }
      UI.user_error!("Syntax error in #{File.basename(file)}")
      next
    end

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

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

      if class_ref.respond_to?(:run)
        UI.success("Successfully loaded custom action '#{file}'.") if FastlaneCore::Globals.verbose?
      else
        UI.error("Could not find method 'run' in class #{class_name}.")
        UI.error('For more information, check out the docs: https://docs.fastlane.tools/')
        UI.user_error!("Action '#{file_name}' is damaged!", show_github_issues: true)
      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://docs.fastlane.tools/')
      UI.user_error!("Action '#{file_name}' is damaged!", show_github_issues: true)
    end
  end
  Actions.reset_aliases

  return class_refs
end

.load_helpersObject

Import all the helpers



99
100
101
102
103
# File 'fastlane/lib/fastlane/actions/actions_helper.rb', line 99

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

.reset_aliasesObject



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

def self.reset_aliases
  @alias_actions = nil
end

.sh(*command, log: true, error_callback: nil, &b) ⇒ 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

  • error_callback (Block) (defaults to: nil)

    a callback invoked with the command output if there is a non-zero exit status



11
12
13
# File 'fastlane/lib/fastlane/helper/sh_helper.rb', line 11

def self.sh(*command, log: true, error_callback: nil, &b)
  sh_control_output(*command, print_command: log, print_command_output: log, error_callback: error_callback, &b)
end

.sh_control_output(*command, print_command: true, print_command_output: true, error_callback: nil) {|status, result, cmd| ... } ⇒ Object

rubocop: disable Metrics/PerceivedComplexity

Parameters:

  • command

    The command to be executed (variadic)

  • print_command (Boolean) (defaults to: true)

    Should we print the command that’s being executed

  • print_command_output (Boolean) (defaults to: true)

    Should we print the command output during execution

  • error_callback (Block) (defaults to: nil)

    A block that’s called if the command exits with a non-zero status

Yields:

  • (status, result, cmd)

    The return status of the command, all output from the command and an equivalent shell command

Yield Parameters:

  • status (Process::Status)

    A Process::Status indicating the status of the completed command

  • result (String)

    The complete output to stdout and stderr of the completed command

  • cmd (String)

    A shell command equivalent to the arguments passed



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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'fastlane/lib/fastlane/helper/sh_helper.rb', line 28

def self.sh_control_output(*command, print_command: true, print_command_output: true, error_callback: nil)
  print_command = print_command_output = true if $troubleshoot
  # 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

  # Workaround to support previous Fastlane syntax.
  # This has some limitations. For example, it requires the caller to shell escape
  # everything because of usages like ["ls -la", "/tmp"] instead of ["ls", "-la", "/tmp"].
  command = [command.first.join(" ")] if command.length == 1 && command.first.kind_of?(Array)

  shell_command = shell_command_from_args(*command)
  UI.command(shell_command) if print_command

  result = ''
  exit_status = nil
  if Helper.sh_enabled?
    # The argument list is passed directly to Open3.popen2e, which
    # handles the variadic argument list in the same way as Kernel#spawn.
    # (http://ruby-doc.org/core-2.4.2/Kernel.html#method-i-spawn) or
    # Process.spawn (http://ruby-doc.org/core-2.4.2/Process.html#method-c-spawn).
    #
    # sh "ls -la /Applications/Xcode\ 7.3.1.app"
    # sh "ls", "-la", "/Applications/Xcode 7.3.1.app"
    # sh({ "FOO" => "Hello" }, "echo $FOO")
    Open3.popen2e(*command) do |stdin, io, thread|
      io.sync = true
      io.each do |line|
        UI.command_output(line.strip) if print_command_output
        result << line
      end
      exit_status = thread.value
    end

    # Checking Process::Status#exitstatus instead of #success? makes for more
    # testable code. (Tests mock exitstatus only.) This is also consistent
    # with previous implementations of sh and... probably portable to all
    # relevant platforms.
    if exit_status.exitstatus != 0
      message = if print_command
                  "Exit status of command '#{shell_command}' was #{exit_status.exitstatus} instead of 0."
                else
                  "Shell command exited with exit status #{exit_status.exitstatus} instead of 0."
                end
      message += "\n#{result}" if print_command_output

      if error_callback || block_given?
        UI.error(message)
        # block notified below, on success or failure
        error_callback && error_callback.call(result)
      else
        UI.shell_error!(message)
      end
    end
  else
    result << shell_command # only for the tests
  end

  if block_given?
    # Avoid yielding nil in tests. $? will be meaningless, but calls to
    # it will not crash. There is no Process::Status.new. The alternative
    # is to move this inside the sh_enabled? check and not yield in tests.
    return yield(exit_status || $?, result, shell_command)
  end
  result
rescue => ex
  raise ex
ensure
  Encoding.default_external = previous_encoding.first
  Encoding.default_internal = previous_encoding.last
end

.sh_no_action(*command, log: true, error_callback: nil, &b) ⇒ Object



15
16
17
# File 'fastlane/lib/fastlane/helper/sh_helper.rb', line 15

def self.sh_no_action(*command, log: true, error_callback: nil, &b)
  sh_control_output(*command, print_command: log, print_command_output: log, error_callback: error_callback, &b)
end

.shell_command_from_args(*args) ⇒ String

Used to produce a shell command string from a list of arguments that may be passed to methods such as Kernel#system, Kernel#spawn and Open3.popen2e in order to print the command to the terminal. The same *args are passed directly to a system call (Open3.popen2e). This interpretation is not used when executing a command.

Parameters:

  • args

    Any number of arguments used to construct a command

Returns:

  • (String)

    A shell command representing the arguments passed in

Raises:

  • (ArgumentError)

    If no arguments passed



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'fastlane/lib/fastlane/helper/sh_helper.rb', line 111

def self.shell_command_from_args(*args)
  raise ArgumentError, "sh requires at least one argument" unless args.count > 0

  command = ""

  # Optional initial environment Hash
  if args.first.kind_of?(Hash)
    command = args.shift.map { |k, v| "#{k}=#{v.shellescape}" }.join(" ") + " "
  end

  # Support [ "/usr/local/bin/foo", "foo" ], "-x", ...
  if args.first.kind_of?(Array)
    command += args.shift.first.shellescape + " " + args.shelljoin
    command.chomp!(" ")
  elsif args.count == 1 && args.first.kind_of?(String)
    command += args.first
  else
    command += args.shelljoin
  end

  command
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 'fastlane/lib/fastlane/helper/gem_helper.rb', line 5

def self.verify_gem!(gem_name)
  begin
    FastlaneRequire.install_gem_if_needed(gem_name: gem_name, require_gem: false)
    # 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.test?
  end
  true
end