summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2015-07-09 14:05:11 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2015-07-09 14:05:11 +0000
commita14db6d3c063724a3ee76ba9a733ba09a4fdea73 (patch)
tree2587758c5f4c3472f42dac6007ea88b447b2299c
parent349a1b80344ba17f27144d1445383576d60b09c6 (diff)
parent9436dca4ed72e0e5bb36f5444ddeb5de9b346c03 (diff)
downloadgitlab-ci-a14db6d3c063724a3ee76ba9a733ba09a4fdea73.tar.gz
Merge branch 'builds-path' into 'master'
Make configurable builds_path in application.yml We have a new option in `application.yml`: ``` gitlab_ci: builds_path: builds/ ``` /cc @marin @vsizov See merge request !193
-rw-r--r--CHANGELOG3
-rw-r--r--app/models/build.rb8
-rw-r--r--config/application.yml.example3
-rw-r--r--config/initializers/1_settings.rb1
-rw-r--r--spec/support/setup_builds_storage.rb10
5 files changed, 15 insertions, 10 deletions
diff --git a/CHANGELOG b/CHANGELOG
index a1a24e0..6631d52 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,10 +10,11 @@ v7.13.0
- Change favicon
- Refactoring: Get rid of private_token usage in the frontend.
- Allow to specify allow_failure for job
+ - Build traces is stored in the file instead of database
+ - Make the builds path configurable
v7.12.2
- Revert: Runner without tag should pick builds without tag only
- - Build traces is stored in the file instead of database
v7.12.1
- Runner without tag should pick builds without tag only
diff --git a/app/models/build.rb b/app/models/build.rb
index 5e65e26..5e6522d 100644
--- a/app/models/build.rb
+++ b/app/models/build.rb
@@ -235,17 +235,13 @@ class Build < ActiveRecord::Base
end
def dir_to_trace
- Rails.root.join(
- root_dir_to_trace,
+ File.join(
+ Settings.gitlab_ci.builds_path,
created_at.utc.strftime("%Y_%m"),
project.id.to_s
)
end
- def root_dir_to_trace
- "builds"
- end
-
def path_to_trace
"#{dir_to_trace}/#{id}.log"
end
diff --git a/config/application.yml.example b/config/application.yml.example
index 8d345b3..d86f68b 100644
--- a/config/application.yml.example
+++ b/config/application.yml.example
@@ -29,6 +29,9 @@ defaults: &defaults
# Add pusher to recipients list (default: false)
# add_pusher: true
+ # The location where build traces are stored (default: builds/). Relative paths are relative to Rails.root
+ # builds_path: builds/
+
gravatar:
enabled: true
plain_url: "http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=mm"
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index dbe4fa1..a8f1107 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -40,6 +40,7 @@ Settings.gitlab_ci['support_email'] ||= Settings.gitlab_ci.email_from
Settings.gitlab_ci['all_broken_builds'] = true if Settings.gitlab_ci['all_broken_builds'].nil?
Settings.gitlab_ci['add_pusher'] = false if Settings.gitlab_ci['add_pusher'].nil?
Settings.gitlab_ci['url'] ||= Settings.send(:build_gitlab_ci_url)
+Settings.gitlab_ci['builds_path'] = File.expand_path(Settings.gitlab_ci['builds_path'] || "builds/", Rails.root)
# Compatibility with old config
Settings['gitlab_server_urls'] ||= Settings['allowed_gitlab_urls']
diff --git a/spec/support/setup_builds_storage.rb b/spec/support/setup_builds_storage.rb
index ab93471..1f3b12b 100644
--- a/spec/support/setup_builds_storage.rb
+++ b/spec/support/setup_builds_storage.rb
@@ -1,11 +1,15 @@
RSpec.configure do |config|
+ def builds_path
+ Rails.root.join('tmp/builds_test')
+ end
+
config.before(:each) do
- FileUtils.mkdir_p("tmp/builds_test")
- Build.any_instance.stub(:root_dir_to_trace).and_return("tmp/builds_test")
+ FileUtils.mkdir_p(builds_path)
+ Settings.gitlab_ci['builds_path'] = builds_path
end
config.after(:suite) do
- Dir.chdir(Rails.root.join("tmp/builds_test")) do
+ Dir.chdir(builds_path) do
`ls | grep -v .gitkeep | xargs rm -r`
end
end