Sha256: 6c76a8a76c0d748675703f5c833ee02fbca549cf4c35d42daea1ec6b7c92a8e1

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

module Buildkite
  module Builder
    module Commands
      class Run < Abstract
        private
        include LoggingUtils
        using Rainbow

        self.description = 'Builds and uploads the generated pipeline.'

        def run
          relative_pipeline_path = pipeline_path.relative_path_from(Builder.root)

          # This entrypoint is for running on CI. It expects certain environment
          # variables to be set. It also uploads the pipeline to Buildkite.
          log.info "+++ 🧰 #{'Buildkite Builder'.color(:springgreen)} v#{Buildkite::Builder.version} ─ #{relative_pipeline_path.to_s.yellow}"

          if Buildkite::Pipelines::Command.meta_data(:get, Builder::META_DATA.fetch(:job)) == Buildkite.env.job_id
            log.info "Pipeline already uploaded in #{Buildkite.env.job_id}".color(:dimgray)
          else
            Pipeline.new(pipeline_path, logger: log).upload
          end
        end

        private

        def pipeline_path
          pipeline_path_override || super
        end

        def pipeline_path_override
          if ENV['BUILDKITE_BUILDER_PIPELINE_PATH']
            path = Pathname.new(ENV['BUILDKITE_BUILDER_PIPELINE_PATH'])
            path.absolute? ? path : Builder.root.join(path)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
buildkite-builder-4.2.1 lib/buildkite/builder/commands/run.rb