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
Jérome Perrin
gitlab-ce
Commits
03a8ed97
Commit
03a8ed97
authored
Oct 13, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use trasaction to process build deployment
parent
204fdcb1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
12 deletions
+16
-12
app/services/create_deployment_service.rb
app/services/create_deployment_service.rb
+16
-12
No files found.
app/services/create_deployment_service.rb
View file @
03a8ed97
...
@@ -2,25 +2,29 @@ require_relative 'base_service'
...
@@ -2,25 +2,29 @@ require_relative 'base_service'
class
CreateDeploymentService
<
BaseService
class
CreateDeploymentService
<
BaseService
def
execute
(
deployable
=
nil
)
def
execute
(
deployable
=
nil
)
environment
=
find_or_create_environment
ActiveRecord
::
Base
.
transaction
do
@deployable
=
deployable
@environment
=
prepare_environment
deployment
=
project
.
deployments
.
create
(
deploy
.
tap
do
|
deployment
|
environment:
environment
,
deployment
.
update_merge_request_metrics!
end
end
end
private
def
deploy
project
.
deployments
.
create
(
environment:
@environment
,
ref:
params
[
:ref
],
ref:
params
[
:ref
],
tag:
params
[
:tag
],
tag:
params
[
:tag
],
sha:
params
[
:sha
],
sha:
params
[
:sha
],
user:
current_user
,
user:
current_user
,
deployable:
deployable
deployable:
@deployable
)
)
deployment
.
update_merge_request_metrics!
deployment
end
end
private
def
prepare_environment
def
find_or_create_environment
project
.
environments
.
find_or_create_by
(
name:
expanded_name
)
do
|
environment
|
project
.
environments
.
find_or_create_by
(
name:
expanded_name
)
do
|
environment
|
environment
.
external_url
=
expanded_url
environment
.
external_url
=
expanded_url
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