module Gitlab::QA::Runtime::Env
Constants
- ENV_VARIABLES
Variables that are used in tests and are passed through to the docker container that executes the tests. These variables should be listed in /docs/what_tests_can_be_run.md#supported-gitlab-environment-variables unless they're defined elsewhere (e.g.: docs.gitlab.com/ee/ci/variables/predefined_variables.html)
Public Instance Methods
aws_s3_access_key()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 233 def aws_s3_access_key ENV['AWS_S3_ACCESS_KEY'] end
aws_s3_bucket_name()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 237 def aws_s3_bucket_name ENV['AWS_S3_BUCKET_NAME'] end
aws_s3_key_id()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 229 def aws_s3_key_id ENV['AWS_S3_KEY_ID'] end
aws_s3_region()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 225 def aws_s3_region ENV['AWS_S3_REGION'] end
ci_api_v4_url()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 145 def ci_api_v4_url ENV['CI_API_V4_URL'] end
ci_commit_ref_name()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 173 def ci_commit_ref_name ENV['CI_COMMIT_REF_NAME'] end
ci_job_name()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 149 def ci_job_name ENV['CI_JOB_NAME'] end
ci_job_token()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 153 def ci_job_token ENV['CI_JOB_TOKEN'] end
ci_pipeline_id()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 165 def ci_pipeline_id ENV['CI_PIPELINE_ID'] end
ci_pipeline_source()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 157 def ci_pipeline_source ENV['CI_PIPELINE_SOURCE'] end
ci_pipeline_url()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 161 def ci_pipeline_url ENV['CI_PIPELINE_URL'] end
ci_project_id()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 169 def ci_project_id ENV['CI_PROJECT_ID'] end
default_branch()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 121 def default_branch ENV['QA_DEFAULT_BRANCH'] || 'main' end
deploy_environment()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 213 def deploy_environment ENV['DEPLOY_ENVIRONMENT'] || pipeline_from_project_name end
dev_access_token_variable()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 193 def dev_access_token_variable env_value_if_defined('GITLAB_QA_DEV_ACCESS_TOKEN') end
elastic_version()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 221 def elastic_version ENV['ELASTIC_VERSION'] || '6.4.2'.freeze end
geo_failover?()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 325 def geo_failover? enabled?(ENV['GEO_FAILOVER'], default: false) end
gitlab_api_base()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 137 def gitlab_api_base ENV['GITLAB_API_BASE'] || 'https://gitlab.com/api/v4' end
gitlab_availability_timeout()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 125 def gitlab_availability_timeout ENV.fetch('GITLAB_QA_AVAILABILITY_TIMEOUT', 360).to_i end
gitlab_ci_api_token()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 141 def gitlab_ci_api_token ENV['GITLAB_CI_API_TOKEN'] end
gitlab_dev_username()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 133 def gitlab_dev_username ENV['GITLAB_DEV_USERNAME'] || 'gitlab-qa-bot' end
gitlab_username()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 129 def gitlab_username ENV['GITLAB_USERNAME'] || 'gitlab-qa' end
host_artifacts_dir()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 217 def host_artifacts_dir @host_artifacts_dir ||= File.join(ENV['QA_ARTIFACTS_DIR'] || '/tmp/gitlab-qa', Runtime::Env.run_id) end
initial_root_password()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 201 def initial_root_password ENV['GITLAB_INITIAL_ROOT_PASSWORD'] || '5iveL!fe' end
override_default_password!()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 314 def override_default_password! require_initial_password! ENV['GITLAB_PASSWORD'] = initial_root_password ENV['GITLAB_ADMIN_PASSWORD'] = initial_root_password end
pipeline_from_project_name()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 177 def pipeline_from_project_name if ci_project_name.to_s.start_with?('gitlab-qa') if ENV['TOP_UPSTREAM_SOURCE_JOB'].to_s.start_with?('https://ops.gitlab.net') 'staging-orchestrated' else QA::Runtime::Env.default_branch end else ci_project_name end end
qa_container_registry_access_token()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 205 def qa_container_registry_access_token ENV['GITLAB_QA_CONTAINER_REGISTRY_ACCESS_TOKEN'] end
qa_dev_access_token()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 197 def qa_dev_access_token ENV['GITLAB_QA_DEV_ACCESS_TOKEN'] end
qa_issue_url()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 209 def qa_issue_url ENV['GITLAB_QA_ISSUE_URL'] end
require_aws_s3_environment!()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 296 def require_aws_s3_environment! %w[AWS_S3_REGION AWS_S3_KEY_ID AWS_S3_ACCESS_KEY AWS_S3_BUCKET_NAME].each do |env_key| raise ArgumentError, "Environment variable #{env_key} must be set to run AWS S3 object storage specs" unless ENV.key?(env_key) end end
require_ci_slack_webhook_url!()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 284 def require_ci_slack_webhook_url! return unless ENV['CI_SLACK_WEBHOOK_URL'].to_s.strip.empty? raise ArgumentError, "Please provide CI_SLACK_WEBHOOK_URL" end
require_initial_password!()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 302 def require_initial_password! return unless ENV['GITLAB_INITIAL_ROOT_PASSWORD'].to_s.strip.empty? raise ArgumentError, "Environment variable GITLAB_INITIAL_ROOT_PASSWORD must be provided to set an initial root password." end
require_kubernetes_environment!()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 290 def require_kubernetes_environment! %w[GCLOUD_ACCOUNT_EMAIL GCLOUD_ACCOUNT_KEY CLOUDSDK_CORE_PROJECT].each do |env_key| raise ArgumentError, "Environment variable #{env_key} must be set to run kubernetes specs" unless ENV.key?(env_key) end end
require_license!()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 254 def require_license! return if ENV.include?('EE_LICENSE') raise ArgumentError, 'GitLab License is not available. Please load a license into EE_LICENSE env variable.' end
require_no_license!()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 260 def require_no_license! return unless ENV.include?('EE_LICENSE') raise ArgumentError, "Unexpected EE_LICENSE provided. Please unset it to continue." end
require_qa_access_token!()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 266 def require_qa_access_token! return unless ENV['GITLAB_QA_ACCESS_TOKEN'].to_s.strip.empty? raise ArgumentError, "Please provide GITLAB_QA_ACCESS_TOKEN" end
require_qa_dev_access_token!()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 272 def require_qa_dev_access_token! return unless ENV['GITLAB_QA_DEV_ACCESS_TOKEN'].to_s.strip.empty? raise ArgumentError, "Please provide GITLAB_QA_DEV_ACCESS_TOKEN" end
require_slack_qa_channel!()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 278 def require_slack_qa_channel! return unless ENV['SLACK_QA_CHANNEL'].to_s.strip.empty? raise ArgumentError, "Please provide SLACK_QA_CHANNEL" end
require_ssh_tunnel!()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 308 def require_ssh_tunnel! %w[TUNNEL_SSH_PRIVATE_KEY TUNNEL_SERVER_HOSTNAME TUNNEL_SSH_USER].each do |env_key| raise ArgumentError, "Environment variable #{env_key} must be set to run tunnel specs" unless ENV.key?(env_key) end end
run_id()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 189 def run_id @run_id ||= "gitlab-qa-run-#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}-#{SecureRandom.hex(4)}" end
skip_pull?()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 321 def skip_pull? enabled?(ENV['QA_SKIP_PULL'], default: false) end
variables()
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 241 def variables vars = {} ENV_VARIABLES.each do |name, attribute| # Variables that are overridden in the environment take precedence # over the defaults specified by the QA runtime. value = env_value_if_defined(name) || send(attribute) # rubocop:disable GitlabSecurity/PublicSend vars[name] = value if value end vars end
Private Instance Methods
enabled?(value, default: true)
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 331 def enabled?(value, default: true) return default if value.nil? (value =~ /^(false|no|0)$/i) != 0 end
env_value_if_defined(variable)
click to toggle source
# File lib/gitlab/qa/runtime/env.rb, line 337 def env_value_if_defined(variable) # Pass through the variables if they are defined in the environment return "$#{variable}" if ENV[variable] end