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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
dda60230
Commit
dda60230
authored
Aug 18, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix build artifacts in fixtures in development env
parent
312c1dce
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
24 deletions
+30
-24
db/fixtures/development/14_builds.rb
db/fixtures/development/14_builds.rb
+30
-24
No files found.
db/fixtures/development/14_builds.rb
View file @
dda60230
...
@@ -69,46 +69,52 @@ class Gitlab::Seeder::Builds
...
@@ -69,46 +69,52 @@ class Gitlab::Seeder::Builds
end
end
def
build_create!
(
pipeline
,
opts
=
{})
def
build_create!
(
pipeline
,
opts
=
{})
attributes
=
build_attributes_for
(
pipeline
,
opts
)
attributes
=
job_attributes
(
pipeline
,
opts
)
.
merge
(
commands:
'$ build command'
)
Ci
::
Build
.
create!
(
attributes
).
tap
do
|
build
|
Ci
::
Build
.
create!
(
attributes
).
tap
do
|
build
|
if
opts
[
:name
].
start_with?
(
'build'
)
setup_artifacts
(
build
)
artifacts_cache_file
(
artifacts_archive_path
)
do
|
file
|
setup_build_log
(
build
)
build
.
artifacts_file
=
file
build
.
save
end
end
end
artifacts_cache_file
(
artifacts_metadata_path
)
do
|
file
|
build
.
artifacts_metadata
=
file
end
end
##
def
setup_artifacts
(
build
)
# We need to set build trace after saving a build (id required)
return
unless
%w[build test]
.
include?
(
build
.
stage
)
# That is why we need `#tap` method instead of passing block
# directly to `Ci::Build#create!`.
artifacts_cache_file
(
artifacts_archive_path
)
do
|
file
|
#
build
.
artifacts_file
=
file
if
%w(running success failed)
.
include?
(
build
.
status
)
end
build
.
trace
=
FFaker
::
Lorem
.
paragraphs
(
6
).
join
(
"
\n\n
"
)
end
artifacts_cache_file
(
artifacts_metadata_path
)
do
|
file
|
build
.
artifacts_metadata
=
file
end
end
def
setup_build_log
(
build
)
##
# We need to set build trace after saving a build (id required)
# That is why we need `#tap` method instead of passing block
# directly to `Ci::Build#create!`.
#
if
%w(running success failed)
.
include?
(
build
.
status
)
build
.
trace
=
FFaker
::
Lorem
.
paragraphs
(
6
).
join
(
"
\n\n
"
)
end
end
end
end
def
commit_status_create!
(
pipeline
,
opts
=
{})
def
commit_status_create!
(
pipeline
,
opts
=
{})
attributes
=
commit_status_attributes_for
(
pipeline
,
opts
)
attributes
=
job_attributes
(
pipeline
,
opts
)
GenericCommitStatus
.
create!
(
attributes
)
GenericCommitStatus
.
create!
(
attributes
)
end
end
def
commit_status_attributes_for
(
pipeline
,
opts
)
def
job_attributes
(
pipeline
,
opts
)
{
name:
'test build'
,
stage:
'test'
,
stage_idx:
stage_index
(
opts
[
:stage
]),
{
name:
'test build'
,
stage:
'test'
,
stage_idx:
stage_index
(
opts
[
:stage
]),
ref:
'master'
,
tag:
false
,
user:
build_user
,
project:
@project
,
pipeline:
pipeline
,
ref:
'master'
,
tag:
false
,
user:
build_user
,
project:
@project
,
pipeline:
pipeline
,
created_at:
Time
.
now
,
updated_at:
Time
.
now
created_at:
Time
.
now
,
updated_at:
Time
.
now
}.
merge
(
opts
)
}.
merge
(
opts
)
end
end
def
build_attributes_for
(
pipeline
,
opts
)
commit_status_attributes_for
(
pipeline
,
opts
).
merge
(
commands:
'$ build command'
)
end
def
build_user
def
build_user
@project
.
team
.
users
.
sample
@project
.
team
.
users
.
sample
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