Class: Fastlane::Actions::BuildkiteMetadataAction

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

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



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

def self.authors
  ['Automattic']
end

.available_optionsObject



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/buildkite_metadata_action.rb', line 33

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :set,
      env_name: 'BUILDKITE_METADATA_SET',
      description: 'The hash of key/value pairs of the meta-data to set',
      type: Hash,
      optional: true,
      default_value: nil
    ),
    FastlaneCore::ConfigItem.new(
      key: :get,
      env_name: 'BUILDKITE_METADATA_GET',
      description: 'The key of the metadata to get the value of',
      type: String,
      optional: true,
      default_value: nil
    ),
  ]
end

.descriptionObject



18
19
20
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/buildkite_metadata_action.rb', line 18

def self.description
  'Set/Get metadata to the current Buildkite build'
end

.detailsObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/buildkite_metadata_action.rb', line 22

def self.details
  <<~DETAILS
    Set and/or get metadata to the current Buildkite build.

    Has to be run on a CI job (where a `buildkite-agent` is running), e.g. typically by a lane
    that is triggered as part of a Buildkite CI step.

    See https://buildkite.com/docs/agent/v3/cli-meta-data
  DETAILS
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/buildkite_metadata_action.rb', line 62

def self.is_supported?(platform)
  true
end

.return_valueObject



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

def self.return_value
  'The value of the Buildkite metadata corresponding to the provided `get` key. `nil` if no `get` parameter was provided.'
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/buildkite_metadata_action.rb', line 4

def self.run(params)
  # Set/Add new metadata values
  params[:set]&.each do |key, value|
    sh('buildkite-agent', 'meta-data', 'set', key.to_s, value.to_s)
  end

  # Return value of existing metadata key
  sh('buildkite-agent', 'meta-data', 'get', params[:get].to_s) unless params[:get].nil?
end