Class: Omnibus::Buildkite
- Inherits:
-
Object
- Object
- Omnibus::Buildkite
- Defined in:
- lib/omnibus/build_system_metadata/buildkite.rb
Overview
Requires environment variables provided by Buildkite
Provides methods for fetching Omnibus project build metadata from Buildkite
Constant Summary collapse
- AMI_ID_ENV_KEY =
Constants for the buildkite environment variables
"BUILDKITE_AGENT_META_DATA_AWS_AMI_ID".freeze
- HOSTNAME_ENV_KEY =
"BUILDKITE_AGENT_META_DATA_HOSTNAME".freeze
- DOCKER_VERSION_ENV_KEY =
"BUILDKITE_AGENT_META_DATA_DOCKER".freeze
- BUILDKITE_COMMAND_ENV_KEY =
"BUILDKITE_COMMAND".freeze
Class Method Summary collapse
-
.ami_id ⇒ String
The AMI ID of the instance the build is happening on.
-
.docker_image ⇒ String
The OS Image that is being used in the Docker build.
-
.docker_version ⇒ String
The version of docker that was used in the build.
-
.hostname ⇒ String
The hostname of the instance the build is happening on.
-
.is_docker_build ⇒ Boolean
A boolean representing if the build is using docker or not.
-
.omnibus_version ⇒ String
The version of Omnibus that is in ‘version.rb`.
- .to_hash ⇒ Object
Class Method Details
.ami_id ⇒ String
This is only present when the instance is a Windows or Linux instance.
Relies on presence of ENV in Buildkite build job.
The AMI ID of the instance the build is happening on.
44 45 46 47 48 49 50 |
# File 'lib/omnibus/build_system_metadata/buildkite.rb', line 44 def ami_id ami_id = "unknown" if !ENV[AMI_ID_ENV_KEY].nil? && !ENV[AMI_ID_ENV_KEY].empty? ami_id = ENV[AMI_ID_ENV_KEY] end ami_id end |
.docker_image ⇒ String
Relies on presence of ENV in Buildkite build job.
The OS Image that is being used in the Docker build
100 101 102 103 104 105 106 |
# File 'lib/omnibus/build_system_metadata/buildkite.rb', line 100 def docker_image buildkite_command = ENV[BUILDKITE_COMMAND_ENV_KEY] if is_docker_build && buildkite_command && buildkite_command.include?("OS_IMAGE") os_image = buildkite_command.match(/OS_IMAGE=(?<image_id>[\S]*)/) os_image[:image_id] end end |
.docker_version ⇒ String
Relies on presence of ENV in Buildkite build job.
The version of docker that was used in the build.
88 89 90 |
# File 'lib/omnibus/build_system_metadata/buildkite.rb', line 88 def docker_version ENV[DOCKER_VERSION_ENV_KEY] if is_docker_build end |
.hostname ⇒ String
This is only present when the instance is a MacOS instance.
Relies on presence of ENV in Buildkite build job.
The hostname of the instance the build is happening on.
62 63 64 65 66 67 68 |
# File 'lib/omnibus/build_system_metadata/buildkite.rb', line 62 def hostname hostname = "unknown" if !ENV[HOSTNAME_ENV_KEY].nil? && !ENV[HOSTNAME_ENV_KEY].empty? && ami_id == "unknown" hostname = ENV[HOSTNAME_ENV_KEY] end hostname end |
.is_docker_build ⇒ Boolean
Relies on presence of ENV in Buildkite build job.
A boolean representing if the build is using docker or not.
77 78 79 |
# File 'lib/omnibus/build_system_metadata/buildkite.rb', line 77 def is_docker_build !ENV[DOCKER_VERSION_ENV_KEY].nil? && !ENV[DOCKER_VERSION_ENV_KEY].empty? ? true : false end |
.omnibus_version ⇒ String
The version of Omnibus that is in ‘version.rb`
113 114 115 |
# File 'lib/omnibus/build_system_metadata/buildkite.rb', line 113 def omnibus_version Omnibus::VERSION end |
.to_hash ⇒ Object
117 118 119 120 121 122 123 124 125 126 |
# File 'lib/omnibus/build_system_metadata/buildkite.rb', line 117 def to_hash ret = {} ret[:ami_id] = ami_id if ami_id != "unknown" ret[:hostname] = hostname if hostname != "unknown" ret[:is_docker_build] = is_docker_build if is_docker_build ret[:docker_version] = docker_version if docker_version ret[:docker_image] = docker_image if docker_image ret[:omnibus_version] = omnibus_version ret end |