File tree Expand file tree Collapse file tree 1 file changed +27
-13
lines changed Expand file tree Collapse file tree 1 file changed +27
-13
lines changed Original file line number Diff line number Diff line change @@ -356,20 +356,18 @@ namespace :github do
356356 env = { 'BUNDLE_GEMFILE' => task [ 'gemfile' ] }
357357 cmd = 'bundle check || bundle install'
358358
359- # For JRuby 9.2, the `bundle install` command failed ocassionally with the NameError.
360- #
361- # Mitigate the flakiness by retrying the command up to 3 times.
362- #
363- # https://github.com/jruby/jruby/issues/7508
364- # https://github.com/jruby/jruby/issues/3656
365- retries = 0
366- begin
359+ if RUBY_PLATFORM == 'java' && RUBY_ENGINE_VERSION . start_with? ( '9.2' )
360+ # For JRuby 9.2, the `bundle install` command failed ocassionally with the NameError.
361+ #
362+ # Mitigate the flakiness by retrying the command up to 3 times.
363+ #
364+ # https://github.com/jruby/jruby/issues/7508
365+ # https://github.com/jruby/jruby/issues/3656
366+ with_retry do
367+ Bundler . with_unbundled_env { sh ( env , cmd ) }
368+ end
369+ else
367370 Bundler . with_unbundled_env { sh ( env , cmd ) }
368- rescue StandardError
369- sleep ( 2 **retries )
370- retries += 1
371- retry if retries < 3
372- raise
373371 end
374372 end
375373 end
@@ -384,5 +382,21 @@ namespace :github do
384382 Bundler . with_unbundled_env { sh ( env , cmd ) }
385383 end
386384 end
385+
386+ def with_retry ( &block )
387+ retries = 0
388+ begin
389+ yield
390+ rescue StandardError => e
391+ rake_output_message (
392+ "Bundle install failure (Attempt: #{ retries + 1 } ): #{ e . class . name } : #{ e . message } , \
393+ Source:\n #{ Array ( e . backtrace ) . join ( "\n " ) } "
394+ )
395+ sleep ( 2 **retries )
396+ retries += 1
397+ retry if retries < 3
398+ raise
399+ end
400+ end
387401end
388402# rubocop:enable Metrics/BlockLength
You can’t perform that action at this time.
0 commit comments