summaryrefslogtreecommitdiff
path: root/app/models/ci/build.rb
diff options
context:
space:
mode:
authorAchilleas Pipinellis <axilleas@axilleas.me>2017-02-02 19:33:33 +0000
committerAchilleas Pipinellis <axilleas@axilleas.me>2017-02-02 19:33:33 +0000
commitc846d3610912bed47404b31c5bc2f190ecbdb93b (patch)
treedd98634af5c2796a6435afe6c1e2a7254d981c8b /app/models/ci/build.rb
parentbb06183d3d8725b328d9f6f05bf5c4a74b93fb36 (diff)
parentb2e5c423d7080644132c70650bc707feb41cd5a9 (diff)
downloadgitlab-ce-update-import-export-docs.tar.gz
Merge branch 'master' into 'update-import-export-docs'update-import-export-docs
# Conflicts: # doc/user/project/settings/import_export.md
Diffstat (limited to 'app/models/ci/build.rb')
-rw-r--r--app/models/ci/build.rb32
1 files changed, 15 insertions, 17 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 5fe8ddf69d7..b1f77bf242c 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -275,29 +275,23 @@ module Ci
end
def update_coverage
- return unless project
- coverage_regex = project.build_coverage_regex
- return unless coverage_regex
coverage = extract_coverage(trace, coverage_regex)
-
- if coverage.is_a? Numeric
- update_attributes(coverage: coverage)
- end
+ update_attributes(coverage: coverage) if coverage.present?
end
def extract_coverage(text, regex)
- begin
- matches = text.scan(Regexp.new(regex)).last
- matches = matches.last if matches.kind_of?(Array)
- coverage = matches.gsub(/\d+(\.\d+)?/).first
+ return unless regex
- if coverage.present?
- coverage.to_f
- end
- rescue
- # if bad regex or something goes wrong we dont want to interrupt transition
- # so we just silentrly ignore error for now
+ matches = text.scan(Regexp.new(regex)).last
+ matches = matches.last if matches.kind_of?(Array)
+ coverage = matches.gsub(/\d+(\.\d+)?/).first
+
+ if coverage.present?
+ coverage.to_f
end
+ rescue
+ # if bad regex or something goes wrong we dont want to interrupt transition
+ # so we just silentrly ignore error for now
end
def has_trace_file?
@@ -522,6 +516,10 @@ module Ci
self.update(artifacts_expire_at: nil)
end
+ def coverage_regex
+ super || project.try(:build_coverage_regex)
+ end
+
def when
read_attribute(:when) || build_attributes_from_config[:when] || 'on_success'
end