lib/buildkite/builder/pipeline.rb in buildkite-builder-4.4.0 vs lib/buildkite/builder/pipeline.rb in buildkite-builder-4.5.0

- old
+ new

@@ -43,23 +43,28 @@ # Generate the pipeline YAML first. contents = to_yaml upload_artifacts - # Upload the pipeline. - Tempfile.create(['pipeline', '.yml']) do |file| - file.sync = true - file.write(contents) + if data.steps.empty? + logger.info "+++ :pipeline: No steps defined, skipping pipeline upload" + else + # Upload the pipeline. + Tempfile.create(['pipeline', '.yml']) do |file| + file.sync = true + file.write(contents) - logger.info "+++ :pipeline: Uploading pipeline" - unless Buildkite::Pipelines::Command.pipeline(:upload, file.path) - logger.info "Pipeline upload failed, saving as artifact…" - Buildkite::Pipelines::Command.artifact!(:upload, file.path) - abort + logger.info "+++ :pipeline: Uploading pipeline" + unless Buildkite::Pipelines::Command.pipeline(:upload, file.path) + logger.info "Pipeline upload failed, saving as artifact…" + Buildkite::Pipelines::Command.artifact!(:upload, file.path) + abort + end end - logger.info "+++ :toolbox: Setting job meta-data to #{Buildkite.env.job_id.color(:yellow)}" - Buildkite::Pipelines::Command.meta_data!(:set, Builder.meta_data.fetch(:job), Buildkite.env.step_id) end + + logger.info "+++ :toolbox: Setting job meta-data to #{Buildkite.env.job_id.color(:yellow)}" + Buildkite::Pipelines::Command.meta_data!(:set, Builder.meta_data.fetch(:job), Buildkite.env.step_id) end def to_h @pipeline_hash ||= begin results = benchmark("\nDone (%s)".color(:springgreen)) do