Class: Fastlane::Actions::SetupJenkinsAction

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

Constant Summary collapse

USED_ENV_NAMES =
[
  "BACKUP_XCARCHIVE_DESTINATION",
  "DERIVED_DATA_PATH",
  "FL_CARTHAGE_DERIVED_DATA",
  "FL_SLATHER_BUILD_DIRECTORY",
  "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

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, deprecated_notes, lane_context, method_missing, other_action, output, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorsObject



174
175
176
# File 'fastlane/lib/fastlane/actions/setup_jenkins.rb', line 174

def self.authors
  ["bartoszj"]
end

.available_optionsObject



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
164
165
166
167
168
169
170
171
172
# File 'fastlane/lib/fastlane/actions/setup_jenkins.rb', line 106

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,
                                 sensitive: 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 built 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

.categoryObject



188
189
190
# File 'fastlane/lib/fastlane/actions/setup_jenkins.rb', line 188

def self.category
  :misc
end

.descriptionObject



86
87
88
# File 'fastlane/lib/fastlane/actions/setup_jenkins.rb', line 86

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

.detailsObject



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'fastlane/lib/fastlane/actions/setup_jenkins.rb', line 90

def self.details
  list = <<-LIST.markdown_list(true)
    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)
  LIST

  [
    list,
    "This action helps with Jenkins integration. Creates own derived data for each job. All build results like IPA files and archives will be stored in the `./output` directory.",
    "The action also works with [Keychains and Provisioning Profiles Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Keychains+and+Provisioning+Profiles+Plugin), the selected keychain will be automatically unlocked and the selected code signing identity will be used. By default this action will only work when _fastlane_ is executed on a CI system."
  ].join("\n")
end

.example_codeObject



182
183
184
185
186
# File 'fastlane/lib/fastlane/actions/setup_jenkins.rb', line 182

def self.example_code
  [
    'setup_jenkins'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



178
179
180
# File 'fastlane/lib/fastlane/actions/setup_jenkins.rb', line 178

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

.run(params) ⇒ Object



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
79
80
# File 'fastlane/lib/fastlane/actions/setup_jenkins.rb', line 20

def self.run(params)
  # Stop if not executed by CI
  if !Helper.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 = 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
    ENV['FL_SLATHER_BUILD_DIRECTORY'] = 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