Class: Fastlane::Actions::GetCircleCiBuildStatusAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/circle_ci/actions/get_circle_ci_build_status.rb

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



90
91
92
# File 'lib/fastlane/plugin/circle_ci/actions/get_circle_ci_build_status.rb', line 90

def self.authors
  ["crazymanish"]
end

.available_optionsObject



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
# File 'lib/fastlane/plugin/circle_ci/actions/get_circle_ci_build_status.rb', line 36

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :api_token,
                                 env_name: "FL_GET_CIRCLE_CI_BUILD_STATUS_API_TOKEN",
                                 description: "API Token for CircleCI API",
                                 sensitive: true,
                                 code_gen_sensitive: true,
                                 is_string: true,
                                 default_value: ENV["CIRCLE_CI_API_TOKEN"],
                                 default_value_dynamic: true,
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :vcs_type,
                                 env_name: "FL_GET_CIRCLE_CI_BUILD_STATUS_VCS_TYPE",
                                 description: "CircleCI vcs type i.e github/bitbucket",
                                 is_string: true,
                                 default_value: "github"),
    FastlaneCore::ConfigItem.new(key: :user_name,
                                 env_name: "FL_GET_CIRCLE_CI_BUILD_STATUS_USER_NAME",
                                 description: "CircleCI project repo user name i.e For github repo 'crazymanish/some_repo_name', user_name will be 'crazymanish'",
                                 is_string: true,
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :project_name,
                                 env_name: "FL_GET_CIRCLE_CI_BUILD_STATUS_PROJECT_NAME",
                                 description: "CircleCI project repo project name i.e For github repo 'crazymanish/some_repo_name', project_name will be 'some_repo_name'",
                                 is_string: true,
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :build_number,
                                 env_name: "FL_GET_CIRCLE_CI_BUILD_STATUS_BUILD_NUMBER",
                                 description: "CircleCI build number",
                                 is_string: true,
                                 optional: false)
  ]
end

.descriptionObject



32
33
34
# File 'lib/fastlane/plugin/circle_ci/actions/get_circle_ci_build_status.rb', line 32

def self.description
  "CircleCI build status"
end

.example_codeObject



80
81
82
83
84
85
86
87
88
# File 'lib/fastlane/plugin/circle_ci/actions/get_circle_ci_build_status.rb', line 80

def self.example_code
  [
    'get_circle_ci_build_status(
      user_name: "crazymanish",
      project_name: "some_repo_name",
      build_number: "1234"
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


94
95
96
# File 'lib/fastlane/plugin/circle_ci/actions/get_circle_ci_build_status.rb', line 94

def self.is_supported?(platform)
  true
end

.outputObject



70
71
72
73
74
# File 'lib/fastlane/plugin/circle_ci/actions/get_circle_ci_build_status.rb', line 70

def self.output
  [
    ['GET_CIRCLE_CI_BUILD_STATUS_RESULT', 'CircleCI build status']
  ]
end

.return_valueObject



76
77
78
# File 'lib/fastlane/plugin/circle_ci/actions/get_circle_ci_build_status.rb', line 76

def self.return_value
  "Returns the CircleCI build status."
end

.run(params) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fastlane/plugin/circle_ci/actions/get_circle_ci_build_status.rb', line 11

def self.run(params)
  token = params[:api_token]
  vcs = params[:vcs_type]
  name = params[:user_name]
  project = params[:project_name]
  build = params[:build_number]

  uri = "https://circleci.com"
  api_url = "api/v1.1/project/#{vcs}/#{name}/#{project}/#{build}"
  curl_command = "curl -H 'Content-Type: application/json' -H 'Circle-Token: #{token}' -s #{uri}/#{api_url}"

  result = Helper::CircleCiHelper.execute(curl_command)

  Actions.lane_context[SharedValues::GET_CIRCLE_CI_BUILD_STATUS_RESULT] = result
  result
end