Skip to content

Commit

Permalink
Merge branch 'ci-artifacts-path' into 'master'
Browse files Browse the repository at this point in the history
Expose artifacts path

This fixes broken artifacts storage path.

Fixes #3607 
Fixes #3608

Related: gitlab-org/omnibus-gitlab!544

See merge request !1869
  • Loading branch information
Robert Speicher authored and rspeicher committed Nov 23, 2015
1 parent 320c86a commit 69383ac
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -7,6 +7,7 @@ v 8.2.1
v 8.2.0
- Improved performance of finding projects and groups in various places
- Improved performance of rendering user profile pages and Atom feeds
- Expose build artifacts path as config option
- Fix grouping of contributors by email in graph.
- Remove CSS property preventing hard tabs from rendering in Chromium 45 (Stan Hu)
- Fix Drone CI service template not saving properly (Stan Hu)
Expand Down
2 changes: 1 addition & 1 deletion app/models/application_setting.rb
Expand Up @@ -99,7 +99,7 @@ def self.create_from_defaults
restricted_signup_domains: Settings.gitlab['restricted_signup_domains'],
import_sources: ['github','bitbucket','gitlab','gitorious','google_code','fogbugz','git'],
shared_runners_enabled: Settings.gitlab_ci['shared_runners_enabled'],
max_artifacts_size: Settings.gitlab_ci['max_artifacts_size'],
max_artifacts_size: Settings.artifacts['max_size'],
)
end

Expand Down
6 changes: 3 additions & 3 deletions app/uploaders/artifact_uploader.rb
Expand Up @@ -5,15 +5,15 @@ class ArtifactUploader < CarrierWave::Uploader::Base
attr_accessor :build, :field

def self.artifacts_path
File.expand_path('shared/artifacts/', Rails.root)
Gitlab.config.artifacts.path
end

def self.artifacts_upload_path
File.expand_path('shared/artifacts/tmp/uploads/', Rails.root)
File.join(self.artifacts_path, 'tmp/uploads/')
end

def self.artifacts_cache_path
File.expand_path('shared/artifacts/tmp/cache/', Rails.root)
File.join(self.artifacts_path, 'tmp/cache/')
end

def initialize(build, field)
Expand Down
6 changes: 6 additions & 0 deletions config/gitlab.yml.example
Expand Up @@ -124,6 +124,12 @@ production: &base
# The mailbox where incoming mail will end up. Usually "inbox".
mailbox: "inbox"

## Build Artifacts
artifacts:
enabled: true
# The location where build artifacts are stored (default: shared/artifacts).
# path: shared/artifacts

## Git LFS
lfs:
enabled: true
Expand Down
9 changes: 8 additions & 1 deletion config/initializers/1_settings.rb
Expand Up @@ -187,7 +187,6 @@ def base_gitlab_url
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)
Settings.gitlab_ci['max_artifacts_size'] ||= 100 # in megabytes

#
# Reply by email
Expand All @@ -199,6 +198,14 @@ def base_gitlab_url
Settings.incoming_email['start_tls'] = false if Settings.incoming_email['start_tls'].nil?
Settings.incoming_email['mailbox'] = "inbox" if Settings.incoming_email['mailbox'].nil?

#
# Build Artifacts
#
Settings['artifacts'] ||= Settingslogic.new({})
Settings.artifacts['enabled'] = true if Settings.artifacts['enabled'].nil?
Settings.artifacts['path'] = File.expand_path(Settings.artifacts['path'] || File.join(Settings.shared['path'], "artifacts"), Rails.root)
Settings.artifacts['max_size'] ||= 100 # in megabytes

#
# Git LFS
#
Expand Down
2 changes: 2 additions & 0 deletions lib/ci/api/builds.rb
Expand Up @@ -58,6 +58,7 @@ class Builds < Grape::API
# POST /builds/:id/artifacts/authorize
post ":id/artifacts/authorize" do
require_gitlab_workhorse!
not_allowed! unless Gitlab.config.artifacts.enabled
build = Ci::Build.find_by_id(params[:id])
not_found! unless build
authenticate_build_token!(build)
Expand Down Expand Up @@ -91,6 +92,7 @@ class Builds < Grape::API
# POST /builds/:id/artifacts
post ":id/artifacts" do
require_gitlab_workhorse!
not_allowed! unless Gitlab.config.artifacts.enabled
build = Ci::Build.find_by_id(params[:id])
not_found! unless build
authenticate_build_token!(build)
Expand Down
2 changes: 1 addition & 1 deletion lib/gitlab/current_settings.rb
Expand Up @@ -25,7 +25,7 @@ def fake_application_settings
session_expire_delay: Settings.gitlab['session_expire_delay'],
import_sources: Settings.gitlab['import_sources'],
shared_runners_enabled: Settings.gitlab_ci['shared_runners_enabled'],
max_artifacts_size: Ci::Settings.gitlab_ci['max_artifacts_size'],
max_artifacts_size: Settings.artifacts['max_size'],
)
end

Expand Down

0 comments on commit 69383ac

Please sign in to comment.