BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
c6bce7e6
Commit
c6bce7e6
authored
Jun 02, 2016
by
Kamil Trzcinski
Committed by
Grzegorz Bizon
Jun 03, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Save Ci::Commit object to persist all created builds
parent
07af37a2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
6 deletions
+21
-6
build.rb
app/models/ci/build.rb
+4
-1
commit.rb
app/models/ci/commit.rb
+4
-2
create_pipeline_service.rb
app/services/ci/create_pipeline_service.rb
+1
-1
create_trigger_request_service.rb
app/services/ci/create_trigger_request_service.rb
+1
-0
commit_spec.rb
spec/models/ci/commit_spec.rb
+6
-2
builds_spec.rb
spec/requests/ci/api/builds_spec.rb
+5
-0
No files found.
app/models/ci/build.rb
View file @
c6bce7e6
...
...
@@ -66,7 +66,10 @@ module Ci
# We use around_transition to create builds for next stage as soon as possible, before the `after_*` is executed
around_transition
any
=>
[
:success
,
:failed
,
:canceled
]
do
|
build
,
block
|
block
.
call
build
.
commit
.
create_next_builds
(
build
)
if
build
.
commit
if
build
.
commit
build
.
commit
.
create_next_builds
(
build
)
build
.
commit
.
save
end
end
after_transition
any
=>
[
:success
,
:failed
,
:canceled
]
do
|
build
|
...
...
app/models/ci/commit.rb
View file @
c6bce7e6
...
...
@@ -13,7 +13,7 @@ module Ci
validate
:valid_commit_sha
# Invalidate object and save if when touched
after_touch
:update_state
!
after_touch
:update_state
def
self
.
truncate_sha
(
sha
)
sha
[
0
...
8
]
...
...
@@ -159,7 +159,9 @@ module Ci
git_commit_message
=~
/(\[ci skip\])/
if
git_commit_message
end
def
update_state!
private
def
update_state
statuses
.
reload
self
.
status
=
if
yaml_errors
.
blank?
statuses
.
latest
.
status
||
'skipped'
...
...
app/services/ci/create_pipeline_service.rb
View file @
c6bce7e6
...
...
@@ -31,7 +31,7 @@ module Ci
pipeline
.
errors
.
add
(
:base
,
'No builds for this pipeline.'
)
end
pipeline
.
update_state!
pipeline
.
save
pipeline
end
...
...
app/services/ci/create_trigger_request_service.rb
View file @
c6bce7e6
...
...
@@ -15,6 +15,7 @@ module Ci
)
if
ci_commit
.
create_builds
(
nil
,
trigger_request
)
ci_commit
.
save
trigger_request
end
end
...
...
spec/models/ci/commit_spec.rb
View file @
c6bce7e6
...
...
@@ -55,11 +55,15 @@ describe Ci::Commit, models: true do
let!
(
:commit
)
{
FactoryGirl
.
create
:ci_commit
,
project:
project
,
ref:
'master'
,
tag:
false
}
def
create_builds
(
trigger_request
=
nil
)
commit
.
create_builds
(
nil
,
trigger_request
)
if
commit
.
create_builds
(
nil
,
trigger_request
)
commit
.
save
end
end
def
create_next_builds
commit
.
create_next_builds
(
commit
.
builds
.
order
(
:id
).
last
)
if
commit
.
create_next_builds
(
commit
.
builds
.
order
(
:id
).
last
)
commit
.
save
end
end
it
'creates builds'
do
...
...
spec/requests/ci/api/builds_spec.rb
View file @
c6bce7e6
...
...
@@ -22,6 +22,7 @@ describe Ci::API::API do
it
"should start a build"
do
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
,
ref:
'master'
)
commit
.
create_builds
(
nil
)
commit
.
save
build
=
commit
.
builds
.
first
post
ci_api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
...
...
@@ -58,6 +59,7 @@ describe Ci::API::API do
it
"returns options"
do
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
,
ref:
'master'
)
commit
.
create_builds
(
nil
)
commit
.
save
post
ci_api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
...
...
@@ -68,6 +70,7 @@ describe Ci::API::API do
it
"returns variables"
do
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
,
ref:
'master'
)
commit
.
create_builds
(
nil
)
commit
.
save
project
.
variables
<<
Ci
::
Variable
.
new
(
key:
"SECRET_KEY"
,
value:
"secret_value"
)
post
ci_api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
...
...
@@ -87,6 +90,7 @@ describe Ci::API::API do
trigger_request
=
FactoryGirl
.
create
(
:ci_trigger_request_with_variables
,
commit:
commit
,
trigger:
trigger
)
commit
.
create_builds
(
nil
,
trigger_request
)
commit
.
save
project
.
variables
<<
Ci
::
Variable
.
new
(
key:
"SECRET_KEY"
,
value:
"secret_value"
)
post
ci_api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
...
...
@@ -105,6 +109,7 @@ describe Ci::API::API do
it
"returns dependent builds"
do
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
,
ref:
'master'
)
commit
.
create_builds
(
nil
,
nil
)
commit
.
save
commit
.
builds
.
where
(
stage:
'test'
).
each
(
&
:success
)
post
ci_api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
...
...
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