From deedcfb4d036b5a51d25ba813a9acc6bc917dd1a Mon Sep 17 00:00:00 2001 From: Xenor Chang Date: Tue, 30 Jan 2024 15:01:42 +0800 Subject: [PATCH] Move BUILDKITE_BUILDER_PIPELINE_PATH override as part of command abstract (#110) * Move BUILDKITE_BUILDER_PIPELINE_PATH override as part of command abstract * Bump version --- CHANGELOG.md | 6 ++++++ VERSION | 2 +- lib/buildkite/builder/commands/abstract.rb | 8 ++++++++ lib/buildkite/builder/commands/run.rb | 13 ------------- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5eac3c..6fc13e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### 4.8.0 +* Move `BUILDKITE_BUILDER_PIPELINE_PATH` override as part of command abstract. + +### 4.7.0 +* Remove warning of method redefined. + ### 4.6.0 * Remove `capture` concept on `Buildkite::Pipelines::Command#run` and replaced with `Buildkite::Pipelines::Command::Result` object to represent `Open3.capture3` result. diff --git a/VERSION b/VERSION index f6cdf40..88f1811 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.7.0 +4.8.0 diff --git a/lib/buildkite/builder/commands/abstract.rb b/lib/buildkite/builder/commands/abstract.rb index 5f9fb56..73ce631 100644 --- a/lib/buildkite/builder/commands/abstract.rb +++ b/lib/buildkite/builder/commands/abstract.rb @@ -81,6 +81,7 @@ def log def pipeline_path @pipeline_path ||= + find_root_by_env_path || find_root_by_main_pipeline || find_root_by_multi_pipeline end @@ -103,6 +104,13 @@ def find_root_by_multi_pipeline end end end + + def find_root_by_env_path + 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 diff --git a/lib/buildkite/builder/commands/run.rb b/lib/buildkite/builder/commands/run.rb index bc385f0..f32339f 100644 --- a/lib/buildkite/builder/commands/run.rb +++ b/lib/buildkite/builder/commands/run.rb @@ -23,19 +23,6 @@ def run 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