Class: Fastlane::Actions::JenkinsJobConfigAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::JenkinsJobConfigAction
- Defined in:
- lib/fastlane/plugin/jenkins_job_config/actions/jenkins_job_config_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .category ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .example_code ⇒ Object
-
.find_template(filename) ⇒ Object
find the template file, or nil if not found.
- .is_supported?(platform) ⇒ Boolean
- .return_value ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
86 87 88 |
# File 'lib/fastlane/plugin/jenkins_job_config/actions/jenkins_job_config_action.rb', line 86 def self. ["Jerome Lacoste"] end |
.available_options ⇒ Object
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 |
# File 'lib/fastlane/plugin/jenkins_job_config/actions/jenkins_job_config_action.rb', line 99 def self. [ FastlaneCore::ConfigItem.new(key: :platform, optional: true, is_string: false, default_value: nil, description: "The platform to generate the config for"), FastlaneCore::ConfigItem.new(key: :product, optional: false, is_string: false, default_value: "", description: "The product to generate the config for"), FastlaneCore::ConfigItem.new(key: :task, optional: true, is_string: true, default_value: "", description: "The name of the task, used if platform not specified"), FastlaneCore::ConfigItem.new(key: :command, optional: true, is_string: true, description: "The command to wrap"), FastlaneCore::ConfigItem.new(key: :lanes, optional: false, type: Array, default_value: "", description: "The lanes to generate the config for"), FastlaneCore::ConfigItem.new(key: :git_url, optional: false, is_string: true, default_value: "", description: "The git url to generate the config for"), FastlaneCore::ConfigItem.new(key: :git_branch, optional: false, is_string: true, default_value: "", description: "The git branch to generate the config for"), FastlaneCore::ConfigItem.new(key: :extra_tasks, optional: true, type: Hash, default_value: {}, description: "The additional tasks to generate the config with"), FastlaneCore::ConfigItem.new(key: :extra_credentials, optional: true, type: Hash, default_value: {}, description: "The additional credentials to generate the config with"), FastlaneCore::ConfigItem.new(key: :artifacts, optional: true, type: Array, default_value: [], description: "The artifacts to keep in the config"), FastlaneCore::ConfigItem.new(key: :timeout, optional: true, type: Integer, default_value: 120, description: "The timeout of the build"), FastlaneCore::ConfigItem.new(key: :assigned_label, optional: true, is_string: true, default_value: 'unity_macosx_slave', description: "The label to restrict builds to") ] end |
.category ⇒ Object
185 186 187 |
# File 'lib/fastlane/plugin/jenkins_job_config/actions/jenkins_job_config_action.rb', line 185 def self.category :misc end |
.description ⇒ Object
82 83 84 |
# File 'lib/fastlane/plugin/jenkins_job_config/actions/jenkins_job_config_action.rb', line 82 def self.description "Generate the config for a Jenkins job" end |
.details ⇒ Object
94 95 96 97 |
# File 'lib/fastlane/plugin/jenkins_job_config/actions/jenkins_job_config_action.rb', line 94 def self.details # Optional: "Given a set of inbuilt ERB templates, maintains our Jenkins job configs" end |
.example_code ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/fastlane/plugin/jenkins_job_config/actions/jenkins_job_config_action.rb', line 171 def self.example_code [ 'jenkins_job_config( platform: "android", product: "BigNumbers", git_url: "git:///...", lanes: [:Hockey, :GooglePlay, :Amazon], extra_tasks: { "Clean target directory" => "rm -rf $WORKSPACE/target/*" }, extra_credentials: { "FASTLANE_PASSWORD" => "FASTLANE_PASSWORD" }, artifacts: [ "*.log", "*.data" ] )' ] end |
.find_template(filename) ⇒ Object
find the template file, or nil if not found
72 73 74 75 76 77 78 79 80 |
# File 'lib/fastlane/plugin/jenkins_job_config/actions/jenkins_job_config_action.rb', line 72 def self.find_template(filename) template = File.join(File.("../../templates", __FILE__), filename) UI.verbose("Looking for template under #{template}") unless File.exist? template UI.verbose("Template #{template} not found") template = nil end template end |
.is_supported?(platform) ⇒ Boolean
163 164 165 166 167 168 169 |
# File 'lib/fastlane/plugin/jenkins_job_config/actions/jenkins_job_config_action.rb', line 163 def self.is_supported?(platform) # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example) # See: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md # # [:ios, :mac, :android].include?(platform) true end |
.return_value ⇒ Object
90 91 92 |
# File 'lib/fastlane/plugin/jenkins_job_config/actions/jenkins_job_config_action.rb', line 90 def self.return_value # If your method provides a return value, you can describe here what it does end |
.run(params) ⇒ Object
4 5 6 7 8 9 10 11 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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/fastlane/plugin/jenkins_job_config/actions/jenkins_job_config_action.rb', line 4 def self.run(params) params = params.values if params.kind_of?(FastlaneCore::Configuration) UI.verbose("Generating config with the following parameters: #{params}") git_url = params[:git_url].strip git_branch = params[:git_branch].strip git_project = git_url.split('/').last product = params[:product].to_s.strip platform = params[:platform] assigned_label = params[:assigned_label] # if a user specifies a platform, it better exists! UI.user_error!("Empty platform") if platform && platform.empty? UI.verbose("Getting template for #{platform}") if platform # search for template by platform name template = self.find_template("#{platform}_config.xml.erb") if platform # fallsback template = self.find_template("default_config.xml.erb") unless template UI.user_error!("Template file not found") unless template suffix = platform || params[:task] project_name = "game_#{product}-#{git_branch}_#{suffix}" dest_dir = "target/#{project_name}" FileUtils.mkdir_p(dest_dir) destination = "#{dest_dir}/config.xml" UI.verbose("Using template #{template} for #{project_name}") # relevant configuration for descriptive_text present_keys = [:product, :platform, :lanes, :command, :task] & params.keys descriptive_text = present_keys.map { |key| "#{key} <strong>#{params[key]}</strong>" }.join(" and ") description = "Builds: #{descriptive_text}" \ "<p><strong>This config was AUTOGENERATED using <code>bundle exec fastlane generate_jenkins_configs</code></strong></p>" \ "<p><strong>Be careful if you modify this</strong>. Your changes might get rewritten. Consider contributing to <a href='https://bitbucket.org/WeWantToKnow/fastlane-plugin-jenkins_job_config'>fastlane-plugin-jenkins_job_config</a> instead.</p>" require 'cgi' # change to lowercase to allow execution on windows description = CGI.escapeHTML(description) parameters = {} if params[:command].nil? lanes = params[:lanes] if lanes and lanes.count > 1 parameters['JENKINS_PARAM_LANE_ENV'] = lanes if lanes.count > 1 params[:command] ||= "./ci_build.sh #{product} #{platform} $JENKINS_PARAM_LANE_ENV" else params[:command] ||= "./ci_build.sh #{product} #{platform} #{lanes[0]}" end UI.("No command specified, used default command: #{params[:command]}") else UI.("Using specified command: #{params[:command]}") end params.merge!({ parameters: parameters, description: description, git_project: git_project, timeout_param: params[:timeout] # Else it will try to call the ruby method timeout in the .erb }) Fastlane::Actions::ErbAction.run( template: template, placeholders: params, destination: destination ) end |