Class: Fastlane::Actions::AuDangerGitlabAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



25
26
27
# File 'lib/fastlane/plugin/au_danger_gitlab/actions/au_danger_gitlab_action.rb', line 25

def self.authors
  ["SzymonMrozek", "emilwojtaszek"]
end

.available_optionsObject



38
39
40
41
42
43
44
45
46
# File 'lib/fastlane/plugin/au_danger_gitlab/actions/au_danger_gitlab_action.rb', line 38

def self.available_options
  [
    # FastlaneCore::ConfigItem.new(key: :your_option,
    #                         env_name: "AU_DANGER_GITLAB_YOUR_OPTION",
    #                      description: "A description of your option",
    #                         optional: false,
    #                             type: String)
  ]
end

.descriptionObject



21
22
23
# File 'lib/fastlane/plugin/au_danger_gitlab/actions/au_danger_gitlab_action.rb', line 21

def self.description
  "Allows to use Danger on GitLab"
end

.detailsObject



33
34
35
36
# File 'lib/fastlane/plugin/au_danger_gitlab/actions/au_danger_gitlab_action.rb', line 33

def self.details
  # Optional:
  "This plugin allows you to use Danger on GitLab by adding CI_MERGE_REQUEST_ID environment value"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
51
52
53
54
# File 'lib/fastlane/plugin/au_danger_gitlab/actions/au_danger_gitlab_action.rb', line 48

def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
  #
  # [:ios, :mac, :android].include?(platform)
  true
end

.return_valueObject



29
30
31
# File 'lib/fastlane/plugin/au_danger_gitlab/actions/au_danger_gitlab_action.rb', line 29

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fastlane/plugin/au_danger_gitlab/actions/au_danger_gitlab_action.rb', line 7

def self.run(params)
  # UI.message("The au_danger_gitlab plugin is working!")
  remotes = sh("git ls-remote -q origin merge-requests\\*head|grep #{ENV['CI_COMMIT_SHA']}")
  match_data = /.*merge-requests\/([0-9]+)\//.match(remotes)
  if match_data && match_data[1]
    ENV['CI_MERGE_REQUEST_ID'] = match_data[1] 
    UI.message("Adding `CI_MERGE_REQUEST_ID` to ENVs")
    return true
  end

  UI.message("Not a merge request, exiting...")
  return false        
end