Class: Publisher::Providers::Info::Gitlab

Inherits:
Base
  • Object
show all
Includes:
Helpers, Singleton
Defined in:
lib/allure_report_publisher/lib/providers/info/gitlab.rb

Overview

Gitlab executor info

Constant Summary

Constants inherited from Base

Base::ALLURE_JOB_NAME, Base::ALLURE_RUN_ID

Instance Method Summary collapse

Methods included from Helpers

allure_cli?, colorize, debug_io, #env, error, execute_shell, log, log_debug, logger, pastel, path, reset_debug_io!

Instance Method Details

#allure_mr_iidString

Custom mr iid name

Returns:

  • (String)


71
72
73
# File 'lib/allure_report_publisher/lib/providers/info/gitlab.rb', line 71

def allure_mr_iid
  @allure_mr_iid ||= env("ALLURE_MERGE_REQUEST_IID")
end

#allure_projectString

Custom repository name

Returns:

  • (String)


57
58
59
# File 'lib/allure_report_publisher/lib/providers/info/gitlab.rb', line 57

def allure_project
  @allure_project ||= env("ALLURE_PROJECT_PATH")
end

#build_nameString

Job name

Returns:

  • (String)


78
79
80
# File 'lib/allure_report_publisher/lib/providers/info/gitlab.rb', line 78

def build_name
  @build_name ||= env(ALLURE_JOB_NAME) || env("CI_JOB_NAME")
end

#build_urlString

Build url

Returns:

  • (String)


50
51
52
# File 'lib/allure_report_publisher/lib/providers/info/gitlab.rb', line 50

def build_url
  @build_url ||= env("CI_PIPELINE_URL")
end

#executor(report_url) ⇒ Hash

Executor info

Returns:

  • (Hash)


13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/allure_report_publisher/lib/providers/info/gitlab.rb', line 13

def executor(report_url)
  {
    name: "Gitlab",
    type: "gitlab",
    reportName: "AllureReport",
    reportUrl: report_url,
    url: server_url,
    buildUrl: build_url,
    buildOrder: run_id,
    buildName: build_name
  }
end

#mr_iidInteger

Merge request iid

Returns:

  • (Integer)


64
65
66
# File 'lib/allure_report_publisher/lib/providers/info/gitlab.rb', line 64

def mr_iid
  @mr_iid ||= allure_mr_iid || env("CI_MERGE_REQUEST_IID")
end

#pr?Boolean

Pull request run

Returns:

  • (Boolean)


29
30
31
# File 'lib/allure_report_publisher/lib/providers/info/gitlab.rb', line 29

def pr?
  !!((allure_project && allure_mr_iid) || mr_iid)
end

#run_idString

Get ci run ID without creating instance of ci provider

Returns:

  • (String)


36
37
38
# File 'lib/allure_report_publisher/lib/providers/info/gitlab.rb', line 36

def run_id
  @run_id ||= env(ALLURE_RUN_ID) || ENV["CI_PIPELINE_ID"]
end

#server_urlString

Server url

Returns:

  • (String)


43
44
45
# File 'lib/allure_report_publisher/lib/providers/info/gitlab.rb', line 43

def server_url
  @server_url ||= env("CI_SERVER_URL")
end