class Fastlane::Actions::JenkinsJobConfigAction
Public Class Methods
available_options()
click to toggle source
# File lib/fastlane/plugin/jenkins_job_config/actions/jenkins_job_config_action.rb, line 99 def self.available_options [ 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()
click to toggle source
# File lib/fastlane/plugin/jenkins_job_config/actions/jenkins_job_config_action.rb, line 185 def self.category :misc end
description()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# 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)
click to toggle source
find the template file, or nil if not found
# File lib/fastlane/plugin/jenkins_job_config/actions/jenkins_job_config_action.rb, line 72 def self.find_template(filename) template = File.join(File.expand_path("../../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)
click to toggle source
# 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()
click to toggle source
# 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)
click to toggle source
# 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.message("No command specified, used default command: #{params[:command]}") else UI.message("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