Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically retry on exit code 255 #124

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/buildkite/config/build_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ def artifact_paths
end

def automatic_retry_on
{ exit_status: -1, limit: 2 }
[
{ exit_status: -1, limit: 2 },
{ exit_status: 255, limit: 2 },
]
end

def timeout_in_minutes
Expand Down
10 changes: 6 additions & 4 deletions lib/buildkite/config/rake_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@ def rake(dir, task: "test", label: nil, service: "default", pre_steps: nil, env:

artifact_paths build_context.artifact_paths

if retry_on
automatic_retry_on(**retry_on)
else
automatic_retry_on(**build_context.automatic_retry_on)
if retry_on ||= build_context.automatic_retry_on
retry_on = [retry_on] unless retry_on.is_a?(Array)

retry_on.each do |retry_rule|
automatic_retry_on(**retry_rule)
end
end

timeout_in_minutes build_context.timeout_in_minutes
Expand Down
2 changes: 1 addition & 1 deletion test/buildkite_config/test_build_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ def test_artifact_paths

def test_automatic_retry_on
sub = create_build_context
assert_equal({ exit_status: -1, limit: 2 }, sub.automatic_retry_on)
assert_equal([{ exit_status: -1, limit: 2 }, { exit_status: 255, limit: 2 }], sub.automatic_retry_on)
end

def test_timeout_in_minutes
Expand Down
2 changes: 1 addition & 1 deletion test/buildkite_config/test_rake_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def test_retry
end

assert_includes pipeline.to_h["steps"][0], "retry"
assert_equal({ "automatic" => [{ "limit" => 2, "exit_status" => -1 }] }, pipeline.to_h["steps"][0]["retry"])
assert_equal({ "automatic" => [{ "limit" => 2, "exit_status" => -1 }, { "limit" => 2, "exit_status" => 255 }] }, pipeline.to_h["steps"][0]["retry"])
end

def test_env
Expand Down