diff --git a/app/controllers/projects/builds_controller.rb b/app/controllers/projects/builds_controller.rb
index 12195c3cbb82704fd93d8648909551a1a75e5f19..4127337cbf26e863f8292904dcfd4176e30a954a 100644
--- a/app/controllers/projects/builds_controller.rb
+++ b/app/controllers/projects/builds_controller.rb
@@ -78,7 +78,7 @@ class Projects::BuildsController < Projects::ApplicationController
   end
 
   def raw
-    if @build.has_trace?
+    if @build.has_trace_file?
       send_file @build.path_to_trace, type: 'text/plain; charset=utf-8', disposition: 'inline'
     else
       render_404
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 23c8de6f6503e72248655d87c89567e9a50a1cc3..76142c4b2b6025736820d937150f5817ec233a2f 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -208,6 +208,10 @@ module Ci
       end
     end
 
+    def has_trace_file?
+      File.exist?(path_to_trace) || (project.ci_id && File.exist?(old_path_to_trace))
+    end
+
     def has_trace?
       raw_trace.present?
     end
diff --git a/app/views/projects/builds/_sidebar.html.haml b/app/views/projects/builds/_sidebar.html.haml
index 5b0b58e087be7dc0c895a516f446ba07f6750fad..49c8bd11634f93719b3e314b1eb800e3b5fda73e 100644
--- a/app/views/projects/builds/_sidebar.html.haml
+++ b/app/views/projects/builds/_sidebar.html.haml
@@ -100,7 +100,7 @@
         - elsif @build.runner
           \##{@build.runner.id}
       .btn-group.btn-group-justified{ role: :group }
-        - if @build.has_trace?
+        - if @build.has_trace_file?
           = link_to 'Raw', raw_namespace_project_build_path(@project.namespace, @project, @build), class: 'btn btn-sm btn-default'
         - if @build.active?
           = link_to "Cancel", cancel_namespace_project_build_path(@project.namespace, @project, @build), class: 'btn btn-sm btn-default', method: :post