Sha256: 4878b9661f5bfbb690db255576ad1149a0f50f1f67b7723a5e63c7b6f1b70b90

Contents?: true

Size: 975 Bytes

Versions: 11

Compression:

Stored size: 975 Bytes

Contents

require "forwardable"

module Buildkite
  module Builder
    class PipelineCollection
      extend Forwardable

      attr_reader :pipelines

      def_delegator :@pipelines, :count
      def_delegator :@pipelines, :each

      def initialize(artifacts)
        @artifacts = artifacts
        @pipelines = []
      end

      def add(pipeline)
        unless pipeline.is_a?(Buildkite::Builder::Extensions::SubPipelines::Pipeline)
          raise "`#{pipeline}` must be a Buildkite::Builder::Extensions::SubPipelines::Pipeline"
        end

        pipelines << pipeline
      end

      def to_definition
        # Instead of generates pipeline.yml, subpipelines save generated file to artifacts
        pipelines.each do |pipeline|
          file = Pathname.new(pipeline.pipeline_yml)
          file.dirname.mkpath
          file.write(YAML.dump(Pipelines::Helpers.sanitize(pipeline.to_h)))

          @artifacts << file
        end

        nil
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
buildkite-builder-3.9.0 lib/buildkite/builder/pipeline_collection.rb
buildkite-builder-3.8.3 lib/buildkite/builder/pipeline_collection.rb
buildkite-builder-3.8.2 lib/buildkite/builder/pipeline_collection.rb
buildkite-builder-3.8.1 lib/buildkite/builder/pipeline_collection.rb
buildkite-builder-3.8.0 lib/buildkite/builder/pipeline_collection.rb
buildkite-builder-3.7.0 lib/buildkite/builder/pipeline_collection.rb
buildkite-builder-3.6.0 lib/buildkite/builder/pipeline_collection.rb
buildkite-builder-3.5.0 lib/buildkite/builder/pipeline_collection.rb
buildkite-builder-3.4.0 lib/buildkite/builder/pipeline_collection.rb
buildkite-builder-3.3.2 lib/buildkite/builder/pipeline_collection.rb
buildkite-builder-3.3.1 lib/buildkite/builder/pipeline_collection.rb