diff --git a/config/configuration.yml.example b/config/configuration.yml.example index 59527f874..4c14fa8f1 100644 --- a/config/configuration.yml.example +++ b/config/configuration.yml.example @@ -133,6 +133,12 @@ default: scm_bazaar_command: scm_darcs_command: + # Absolute path to the scm commands errors (stderr) log file. + # The default is to log in the 'log' directory of your Redmine instance. + # Example: + # scm_stderr_log_file: /var/log/redmine_scm_stderr.log + scm_stderr_log_file: + # Key used to encrypt sensitive data in the database (SCM and LDAP passwords). # If you don't want to enable data encryption, just leave it blank. # WARNING: losing/changing this key will make encrypted data unreadable. diff --git a/lib/redmine/scm/adapters/abstract_adapter.rb b/lib/redmine/scm/adapters/abstract_adapter.rb index 4458baa7e..436d83bf4 100644 --- a/lib/redmine/scm/adapters/abstract_adapter.rb +++ b/lib/redmine/scm/adapters/abstract_adapter.rb @@ -218,14 +218,19 @@ module Redmine Rails.logger end + # Path to the file where scm stderr output is logged + def self.stderr_log_file + @stderr_log_path ||= + Redmine::Configuration['scm_stderr_log_file'].presence || + Rails.root.join("log/#{Rails.env}.scm.stderr.log").to_s + end + def self.shellout(cmd, options = {}, &block) if logger && logger.debug? logger.debug "Shelling out: #{strip_credential(cmd)}" end - if Rails.env == 'development' - # Capture stderr when running in dev environment - cmd = "#{cmd} 2>>#{shell_quote(Rails.root.join('log/scm.stderr.log').to_s)}" - end + # Capture stderr in a log file + cmd = "#{cmd} 2>>#{shell_quote(stderr_log_file)}" begin mode = "r+" IO.popen(cmd, mode) do |io|