Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
8c021a2e
Commit
8c021a2e
authored
Nov 09, 2017
by
Zeger-Jan van de Weg
Committed by
Kamil Trzcinski
Dec 03, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EE specific changes for multiple artifacts
parent
e5580913
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
23 deletions
+33
-23
app/uploaders/job_artifact_uploader.rb
app/uploaders/job_artifact_uploader.rb
+8
-16
db/migrate/20170918072949_add_file_store_job_artifacts.rb
db/migrate/20170918072949_add_file_store_job_artifacts.rb
+17
-0
db/schema.rb
db/schema.rb
+2
-0
spec/factories/ci/job_artifacts.rb
spec/factories/ci/job_artifacts.rb
+5
-0
spec/uploaders/artifact_uploader_spec.rb
spec/uploaders/artifact_uploader_spec.rb
+1
-7
No files found.
app/uploaders/job_artifact_uploader.rb
View file @
8c021a2e
class
JobArtifactUploader
<
Gitlab
Uploader
storage
:file
class
JobArtifactUploader
<
ObjectStore
Uploader
storage
_options
Gitlab
.
config
.
artifacts
def
self
.
local_
artifacts_store
def
self
.
local_
store_path
Gitlab
.
config
.
artifacts
.
path
end
...
...
@@ -9,30 +9,22 @@ class JobArtifactUploader < GitlabUploader
File
.
join
(
self
.
local_artifacts_store
,
'tmp/uploads/'
)
end
def
initialize
(
artifact
,
_field
)
@artifact
=
artifact
end
def
size
return
super
if
@artifact
.
size
.
nil?
@artifact
.
size
end
return
super
if
subject
.
size
.
nil?
def
store_dir
File
.
join
(
self
.
class
.
local_artifacts_store
,
default_path
)
subject
.
size
end
private
def
default_path
creation_date
=
@artifa
ct
.
created_at
.
utc
.
strftime
(
'%Y_%m_%d'
)
creation_date
=
subje
ct
.
created_at
.
utc
.
strftime
(
'%Y_%m_%d'
)
File
.
join
(
disk_hash
[
0
..
1
],
disk_hash
[
2
..
3
],
disk_hash
,
creation_date
,
@artifact
.
job_id
.
to_s
,
@artifa
ct
.
id
.
to_s
)
creation_date
,
subject
.
job_id
.
to_s
,
subje
ct
.
id
.
to_s
)
end
def
disk_hash
@disk_hash
||=
Digest
::
SHA2
.
hexdigest
(
@artifa
ct
.
project_id
.
to_s
)
@disk_hash
||=
Digest
::
SHA2
.
hexdigest
(
subje
ct
.
project_id
.
to_s
)
end
end
db/migrate/20170918072949_add_file_store_job_artifacts.rb
0 → 100644
View file @
8c021a2e
class
AddFileStoreJobArtifacts
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
disable_ddl_transaction!
DOWNTIME
=
false
def
up
add_column
(
:ci_job_artifacts
,
:file_store
,
:integer
)
# Run on an empty table, but else Rubocop is not happy
add_concurrent_index
(
:ci_job_artifacts
,
:file_store
)
end
def
down
drop_column
(
:ci_job_artifacts
,
:file_store
)
end
end
db/schema.rb
View file @
8c021a2e
...
...
@@ -404,8 +404,10 @@ ActiveRecord::Schema.define(version: 20171124165823) do
t
.
datetime_with_timezone
"created_at"
,
null:
false
t
.
datetime_with_timezone
"updated_at"
,
null:
false
t
.
string
"file"
t
.
integer
"file_store"
end
add_index
"ci_job_artifacts"
,
[
"file_store"
],
name:
"index_ci_job_artifacts_on_file_store"
,
using: :btree
add_index
"ci_job_artifacts"
,
[
"file_type"
],
name:
"index_ci_job_artifacts_on_file_type"
,
using: :btree
add_index
"ci_job_artifacts"
,
[
"job_id"
],
name:
"index_ci_job_artifacts_on_job_id"
,
using: :btree
add_index
"ci_job_artifacts"
,
[
"project_id"
],
name:
"index_ci_job_artifacts_on_project_id"
,
using: :btree
...
...
spec/factories/ci/job_artifacts.rb
View file @
8c021a2e
...
...
@@ -4,6 +4,11 @@ FactoryGirl.define do
factory
:ci_job_artifact
,
class:
Ci
::
JobArtifact
do
job
factory: :ci_build
file_type
:archive
file_store
JobArtifactUploader
::
LOCAL_STORE
trait
:remote_store
do
file_store
JobArtifactUploader
::
REMOTE_STORE
end
after
:build
do
|
artifact
|
artifact
.
project
||=
artifact
.
job
.
project
...
...
spec/uploaders/artifact_uploader_spec.rb
View file @
8c021a2e
...
...
@@ -2,7 +2,7 @@ require 'rails_helper'
describe
ArtifactUploader
do
let
(
:store
)
{
described_class
::
LOCAL_STORE
}
s
et
(
:job
)
{
create
(
:ci_build
,
artifacts_file_store:
store
)
}
l
et
(
:job
)
{
create
(
:ci_build
,
artifacts_file_store:
store
)
}
let
(
:uploader
)
{
described_class
.
new
(
job
,
:artifacts_file
)
}
let
(
:local_path
)
{
Gitlab
.
config
.
artifacts
.
path
}
...
...
@@ -66,11 +66,5 @@ describe ArtifactUploader do
subject
{
uploader
.
filename
}
it
{
is_expected
.
to
be_nil
}
context
'with artifacts'
do
let
(
:job
)
{
create
(
:ci_build
,
:artifacts
)
}
it
{
is_expected
.
not_to
be_nil
}
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment