Class: Fastlane::Actions::CircleciTriggerJobAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/wpmreleasetoolkit/actions/common/circleci_trigger_job_action.rb

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



54
55
56
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/circleci_trigger_job_action.rb', line 54

def self.authors
  ['Automattic']
end

.available_optionsObject



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
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/circleci_trigger_job_action.rb', line 27

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :circle_ci_token,
                                 env_name: 'FL_CIRCLECI_TOKEN',
                                 description: 'CircleCI token',
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :organization,
                                 env_name: 'FL_CIRCLECI_ORGANIZATION',
                                 description: 'The GitHub organization which hosts the repository you want to work on',
                                 type: String,
                                 default_value: 'wordpress-mobile'),
    FastlaneCore::ConfigItem.new(key: :repository,
                                 env_name: 'FL_CIRCLECI_REPOSITORY',
                                 description: 'The GitHub repository you want to work on',
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :branch,
                                 env_name: 'FL_CIRCLECI_BRANCH',
                                 description: 'The branch on which you want to work on',
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :job_params,
                                 env_name: 'FL_CIRCLECI_JOB_PARAMS',
                                 description: 'Parameters to send to the CircleCI pipeline',
                                 type: Hash,
                                 default_value: nil),
  ]
end

.descriptionObject



23
24
25
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/circleci_trigger_job_action.rb', line 23

def self.description
  'Triggers a job on CircleCI'
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/circleci_trigger_job_action.rb', line 58

def self.is_supported?(platform)
  true
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/circleci_trigger_job_action.rb', line 4

def self.run(params)
  require_relative '../../helper/ci_helper'

  UI.message "Triggering job #{params[:job_params]} on branch #{params[:branch]}"

  ci_helper = Fastlane::Helper::CircleCIHelper.new(
    login: params[:circle_ci_token],
    repository: params[:repository],
    organization: params[:organization]
  )

  res = ci_helper.trigger_job(branch: params[:branch], parameters: params[:job_params])
  res.code == '201' ? UI.message('Done!') : UI.user_error!("Failed to start job\nError: [#{res.code}] #{res.message}")
end