Class: Publisher::Providers::Info::Gitlab
- 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
-
#allure_mr_iid ⇒ Integer
Custom mr iid name.
-
#allure_project ⇒ String
Custom repository name.
- #branch ⇒ Object
-
#build_dir ⇒ String
Project directory.
-
#build_name ⇒ String
Job name used in report.
-
#build_url ⇒ String
Build url.
-
#client ⇒ Gitlab::Client
Get gitlab client.
-
#executor(report_url) ⇒ Hash
Executor info.
-
#job_id ⇒ Integer
CI job ID.
-
#job_name ⇒ String
CI job name.
-
#mr_iid ⇒ Integer
Merge request iid.
-
#pr? ⇒ Boolean
Pull request run.
-
#project_id ⇒ Integer
CI project ID.
-
#project_path ⇒ String
Full project path.
-
#run_id ⇒ Integer
Get ci run ID without creating instance of ci provider.
-
#server_url ⇒ String
Server url.
Methods included from Helpers
allure_cli?, colorize, debug_io, #env, #env_int, error, execute_shell, log, log_debug, logger, pastel, path, reset_debug_io!
Instance Method Details
#allure_mr_iid ⇒ Integer
Custom mr iid name
117 118 119 |
# File 'lib/allure_report_publisher/lib/providers/info/gitlab.rb', line 117 def allure_mr_iid @allure_mr_iid ||= env_int("ALLURE_MERGE_REQUEST_IID") end |
#allure_project ⇒ String
Custom repository name
103 104 105 |
# File 'lib/allure_report_publisher/lib/providers/info/gitlab.rb', line 103 def allure_project @allure_project ||= env("ALLURE_PROJECT_PATH") end |
#branch ⇒ Object
82 83 84 |
# File 'lib/allure_report_publisher/lib/providers/info/gitlab.rb', line 82 def branch @branch ||= env("CI_MERGE_REQUEST_SOURCE_BRANCH_NAME") || env("CI_COMMIT_REF_NAME") end |
#build_dir ⇒ String
Project directory
78 79 80 |
# File 'lib/allure_report_publisher/lib/providers/info/gitlab.rb', line 78 def build_dir @build_dir ||= env("CI_PROJECT_DIR") end |
#build_name ⇒ String
Job name used in report
124 125 126 |
# File 'lib/allure_report_publisher/lib/providers/info/gitlab.rb', line 124 def build_name @build_name ||= env(ALLURE_JOB_NAME) || job_name end |
#build_url ⇒ String
Build url
96 97 98 |
# File 'lib/allure_report_publisher/lib/providers/info/gitlab.rb', line 96 def build_url @build_url ||= env("CI_PIPELINE_URL") end |
#client ⇒ Gitlab::Client
Get gitlab client
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/allure_report_publisher/lib/providers/info/gitlab.rb', line 29 def client @client ||= begin raise("Missing GITLAB_AUTH_TOKEN environment variable!") unless env("GITLAB_AUTH_TOKEN") ::Gitlab::Client.new( endpoint: "#{server_url}/api/v4", private_token: env("GITLAB_AUTH_TOKEN") ) end end |
#executor(report_url) ⇒ Hash
Executor info
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 |
#job_id ⇒ Integer
CI job ID
57 58 59 |
# File 'lib/allure_report_publisher/lib/providers/info/gitlab.rb', line 57 def job_id @job_id ||= env_int("CI_JOB_ID") end |
#job_name ⇒ String
CI job name
131 132 133 |
# File 'lib/allure_report_publisher/lib/providers/info/gitlab.rb', line 131 def job_name @job_name ||= env("CI_JOB_NAME") end |
#mr_iid ⇒ Integer
Merge request iid
110 111 112 |
# File 'lib/allure_report_publisher/lib/providers/info/gitlab.rb', line 110 def mr_iid @mr_iid ||= allure_mr_iid || env_int("CI_MERGE_REQUEST_IID") end |
#pr? ⇒ Boolean
Pull request run
43 44 45 |
# File 'lib/allure_report_publisher/lib/providers/info/gitlab.rb', line 43 def pr? !!((allure_project && allure_mr_iid) || mr_iid) end |
#project_id ⇒ Integer
CI project ID
71 72 73 |
# File 'lib/allure_report_publisher/lib/providers/info/gitlab.rb', line 71 def project_id @project_id ||= env_int("CI_PROJECT_ID") end |
#project_path ⇒ String
Full project path
64 65 66 |
# File 'lib/allure_report_publisher/lib/providers/info/gitlab.rb', line 64 def project_path @project_path ||= env("CI_PROJECT_PATH") end |
#run_id ⇒ Integer
Get ci run ID without creating instance of ci provider
50 51 52 |
# File 'lib/allure_report_publisher/lib/providers/info/gitlab.rb', line 50 def run_id @run_id ||= env_int(ALLURE_RUN_ID) || env_int("CI_PIPELINE_ID") end |
#server_url ⇒ String
Server url
89 90 91 |
# File 'lib/allure_report_publisher/lib/providers/info/gitlab.rb', line 89 def server_url @server_url ||= env("CI_SERVER_URL") end |