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
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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
12 deletions
+16
-12
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