diff --git a/app/models/git_repository.rb b/app/models/git_repository.rb index e94c1faa1..3b873f8a1 100644 --- a/app/models/git_repository.rb +++ b/app/models/git_repository.rb @@ -1,4 +1,7 @@ # frozen_string_literal: true + +require 'tempfile' + # Responsible for all git knowledge of a repo # Caches a local mirror (not a full checkout) and creates a workspace when deploying class GitRepository @@ -184,13 +187,17 @@ def instance_cache(key) # success: stdout as string # error: nil def capture_stdout(*command, dir: repo_cache_dir) - success, output = Samson::CommandExecutor.execute( - *command, - whitelist_env: ['HOME', 'PATH'], - timeout: 30.minutes, - err: '/dev/null', - dir: dir - ) - output.strip if success + Tempfile.new('git-stderr') do |error_file| + success, output = Samson::CommandExecutor.execute( + *command, + whitelist_env: ['HOME', 'PATH'], + timeout: 30.minutes, + err: error_file.path, + dir: dir + ) + Rails.logger.error("Failed to run command #{command}: #{error_file.read}") unless success + + output.strip if success + end end end