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'
class
CreateDeploymentService
<
BaseService
def
execute
(
deployable
=
nil
)
environment
=
find_or_create_environment
ActiveRecord
::
Base
.
transaction
do
@deployable
=
deployable
@environment
=
prepare_environment
deployment
=
project
.
deployments
.
create
(
environment:
environment
,
deploy
.
tap
do
|
deployment
|
deployment
.
update_merge_request_metrics!
end
end
end
private
def
deploy
project
.
deployments
.
create
(
environment:
@environment
,
ref:
params
[
:ref
],
tag:
params
[
:tag
],
sha:
params
[
:sha
],
user:
current_user
,
deployable:
deployable
)
deployment
.
update_merge_request_metrics!
deployment
deployable:
@deployable
)
end
private
def
find_or_create_environment
def
prepare_environment
project
.
environments
.
find_or_create_by
(
name:
expanded_name
)
do
|
environment
|
environment
.
external_url
=
expanded_url
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