Class: Fastlane::Actions::SetupJenkinsAction

Inherits:
Fastlane::Action show all
Defined in:
lib/fastlane/actions/setup_jenkins.rb

Constant Summary collapse

USED_ENV_NAMES =
[
  "BACKUP_XCARCHIVE_DESTINATION",
  "DERIVED_DATA_PATH",
  "FL_CARTHAGE_DERIVED_DATA",
  "GYM_BUILD_PATH",
  "GYM_CODE_SIGNING_IDENTITY",
  "GYM_DERIVED_DATA_PATH",
  "GYM_OUTPUT_DIRECTORY",
  "GYM_RESULT_BUNDLE",
  "SCAN_DERIVED_DATA_PATH",
  "SCAN_OUTPUT_DIRECTORY",
  "SCAN_RESULT_BUNDLE",
  "XCODE_DERIVED_DATA_PATH"
].freeze

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, method_missing, other_action, output, return_value, sh, step_text

Class Method Details

.authorsObject



165
166
167
# File 'lib/fastlane/actions/setup_jenkins.rb', line 165

def self.authors
  ["bartoszj"]
end

.available_optionsObject



98
99
100
101
102
103
104
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/fastlane/actions/setup_jenkins.rb', line 98

def self.available_options
  [
    # General
    FastlaneCore::ConfigItem.new(key: :force,
                                 env_name: "FL_SETUP_JENKINS_FORCE",
                                 description: "Force setup, even if not executed by Jenkins",
                                 is_string: false,
                                 default_value: false),

    # Keychain
    FastlaneCore::ConfigItem.new(key: :unlock_keychain,
                                 env_name: "FL_SETUP_JENKINS_UNLOCK_KEYCHAIN",
                                 description: "Unlocks keychain",
                                 is_string: false,
                                 default_value: true),
    FastlaneCore::ConfigItem.new(key: :add_keychain_to_search_list,
                                 env_name: "FL_SETUP_JENKINS_ADD_KEYCHAIN_TO_SEARCH_LIST",
                                 description: "Add to keychain search list",
                                 is_string: false,
                                 default_value: :replace),
    FastlaneCore::ConfigItem.new(key: :set_default_keychain,
                                 env_name: "FL_SETUP_JENKINS_SET_DEFAULT_KEYCHAIN",
                                 description: "Set keychain as default",
                                 is_string: false,
                                 default_value: true),
    FastlaneCore::ConfigItem.new(key: :keychain_path,
                                 env_name: "KEYCHAIN_PATH",
                                 description: "Path to keychain",
                                 is_string: true,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :keychain_password,
                                 env_name: "KEYCHAIN_PASSWORD",
                                 description: "Keychain password",
                                 is_string: true,
                                 default_value: ""),

    # Code signing identity
    FastlaneCore::ConfigItem.new(key: :set_code_signing_identity,
                                 env_name: "FL_SETUP_JENKINS_SET_CODE_SIGNING_IDENTITY",
                                 description: "Set code signing identity from CODE_SIGNING_IDENTITY environment",
                                 is_string: false,
                                 default_value: true),
    FastlaneCore::ConfigItem.new(key: :code_signing_identity,
                                 env_name: "CODE_SIGNING_IDENTITY",
                                 description: "Code signing identity",
                                 is_string: true,
                                 optional: true),

    # Xcode parameters
    FastlaneCore::ConfigItem.new(key: :output_directory,
                                 env_name: "FL_SETUP_JENKINS_OUTPUT_DIRECTORY",
                                 description: "The directory in which the ipa file should be stored in",
                                 is_string: true,
                                 default_value: "./output"),
    FastlaneCore::ConfigItem.new(key: :derived_data_path,
                                 env_name: "FL_SETUP_JENKINS_DERIVED_DATA_PATH",
                                 description: "The directory where build products and other derived data will go",
                                 is_string: true,
                                 default_value: "./derivedData"),
    FastlaneCore::ConfigItem.new(key: :result_bundle,
                                 env_name: "FL_SETUP_JENKINS_RESULT_BUNDLE",
                                 description: "Produce the result bundle describing what occurred will be placed",
                                 is_string: false,
                                 default_value: true)
  ]
end

.descriptionObject



84
85
86
# File 'lib/fastlane/actions/setup_jenkins.rb', line 84

def self.description
  "Setup xcodebuild, gym and scan for easier Jenkins integration"
end

.detailsObject



88
89
90
91
92
93
94
95
96
# File 'lib/fastlane/actions/setup_jenkins.rb', line 88

def self.details
  [
    "- Adds and unlocks keychains from Jenkins 'Keychains and Provisioning Profiles Plugin'",
    "- Sets code signing identity from Jenkins 'Keychains and Provisioning Profiles Plugin'",
    "- Sets output directory to './output' (gym, scan and backup_xcarchive).",
    "- Sets derived data path to './derivedData' (xcodebuild, gym, scan and clear_derived_data, carthage).",
    "- Produce result bundle (gym and scan)."
  ].join("\n")
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


169
170
171
# File 'lib/fastlane/actions/setup_jenkins.rb', line 169

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

.run(params) ⇒ Object



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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/fastlane/actions/setup_jenkins.rb', line 19

def self.run(params)
  # Stop if not executed by CI
  if !Helper.is_ci? && !params[:force]
    UI.important "Not executed by Continuous Integration system."
    return
  end

  # Print table
  FastlaneCore::PrintTable.print_values(
    config: params,
    title: "Summary for Setup Jenkins Action"
  )

  # Keychain
  if params[:unlock_keychain] && params[:keychain_path]
    keychain_path = File.expand_path(params[:keychain_path])
    UI.message "Unlocking keychain: \"#{keychain_path}\"."
    Actions::UnlockKeychainAction.run(
      path: keychain_path,
      password: params[:keychain_password],
      add_to_search_list: params[:add_keychain_to_search_list],
      set_default: params[:set_default_keychain]
    )
  end

  # Code signing identity
  if params[:set_code_signing_identity] && params[:code_signing_identity]
    code_signing_identity = params[:code_signing_identity]
    UI.message "Set code signing identity: \"#{code_signing_identity}\"."
    ENV['GYM_CODE_SIGNING_IDENTITY'] = code_signing_identity
  end

  # Set output directory
  if params[:output_directory]
    output_directory_path = File.expand_path(params[:output_directory])
    UI.message "Set output directory path to: \"#{output_directory_path}\"."
    ENV['GYM_BUILD_PATH'] = output_directory_path
    ENV['GYM_OUTPUT_DIRECTORY'] = output_directory_path
    ENV['SCAN_OUTPUT_DIRECTORY'] = output_directory_path
    ENV['BACKUP_XCARCHIVE_DESTINATION'] = output_directory_path
  end

  # Set derived data
  if params[:derived_data_path]
    derived_data_path = File.expand_path(params[:derived_data_path])
    UI.message "Set derived data path to: \"#{derived_data_path}\"."
    ENV['DERIVED_DATA_PATH'] = derived_data_path # Used by clear_derived_data.
    ENV['XCODE_DERIVED_DATA_PATH'] = derived_data_path
    ENV['GYM_DERIVED_DATA_PATH'] = derived_data_path
    ENV['SCAN_DERIVED_DATA_PATH'] = derived_data_path
    ENV['FL_CARTHAGE_DERIVED_DATA'] = derived_data_path
  end

  # Set result bundle
  if params[:result_bundle]
    UI.message "Set result bundle."
    ENV['GYM_RESULT_BUNDLE'] = "YES"
    ENV['SCAN_RESULT_BUNDLE'] = "YES"
  end
end