summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2015-07-08 16:45:13 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2015-07-08 16:45:13 +0200
commit9436dca4ed72e0e5bb36f5444ddeb5de9b346c03 (patch)
tree3757286967a44e89f9e3e76231e6d44ba2265bb6
parent00b6536f4d155ec41b8a8434d992b6b207f07bb5 (diff)
downloadgitlab-ci-9436dca4ed72e0e5bb36f5444ddeb5de9b346c03.tar.gz
Make configurable builds_path in application.ymlbuilds-path
-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 76050f1..39ac254 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,10 +9,11 @@ v7.13.0
- Redirect back after authorization
- Change favicon
- Refactoring: Get rid of private_token usage in the frontend.
+ - 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 51c2bf6..d25e858 100644
--- a/app/models/build.rb
+++ b/app/models/build.rb
@@ -229,17 +229,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