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
f6260328
Commit
f6260328
authored
Jun 02, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix other use of CreateDeploymentService and make
it a bit more robust against missing options, which we did guard on for some cases.
parent
e9a98d3d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
15 deletions
+40
-15
build.rb
app/models/ci/build.rb
+1
-1
create_deployment_service.rb
app/services/create_deployment_service.rb
+1
-1
17_cycle_analytics.rb
db/fixtures/development/17_cycle_analytics.rb
+3
-6
create_deployment_service_spec.rb
spec/services/create_deployment_service_spec.rb
+0
-1
cycle_analytics_helpers.rb
spec/support/cycle_analytics_helpers.rb
+35
-6
No files found.
app/models/ci/build.rb
View file @
f6260328
...
...
@@ -148,7 +148,7 @@ module Ci
return
@environment_url
if
defined?
(
@environment_url
)
@environment_url
=
if
unexpanded_url
=
options
.
dig
(
:environment
,
:url
)
if
unexpanded_url
=
options
&
.
dig
(
:environment
,
:url
)
ExpandVariables
.
expand
(
unexpanded_url
,
simple_variables
)
else
persisted_environment
&
.
external_url
...
...
app/services/create_deployment_service.rb
View file @
f6260328
...
...
@@ -46,7 +46,7 @@ class CreateDeploymentService
end
def
environment_options
@environment_options
||=
job
.
options
[
:environment
]
||
{}
@environment_options
||=
job
.
options
&
.
dig
(
:environment
)
||
{}
end
def
on_stop
...
...
db/fixtures/development/17_cycle_analytics.rb
View file @
f6260328
...
...
@@ -212,12 +212,9 @@ class Gitlab::Seeder::CycleAnalytics
merge_requests
.
each
do
|
merge_request
|
Timecop
.
travel
12
.
hours
.
from_now
CreateDeploymentService
.
new
(
merge_request
.
project
,
@user
,
{
environment:
'production'
,
ref:
'master'
,
tag:
false
,
sha:
@project
.
repository
.
commit
(
'master'
).
sha
}).
execute
job
=
merge_request
.
head_pipeline
.
builds
.
where
.
not
(
environment:
nil
).
last
CreateDeploymentService
.
new
(
job
).
execute
end
end
end
...
...
spec/services/create_deployment_service_spec.rb
View file @
f6260328
...
...
@@ -17,7 +17,6 @@ describe CreateDeploymentService, services: true do
let
(
:service
)
{
described_class
.
new
(
job
)
}
describe
'#execute'
do
subject
{
service
.
execute
}
context
'when no environments exist'
do
...
...
spec/support/cycle_analytics_helpers.rb
View file @
f6260328
...
...
@@ -51,12 +51,41 @@ module CycleAnalyticsHelpers
end
def
deploy_master
(
environment:
'production'
)
CreateDeploymentService
.
new
(
project
,
user
,
{
environment:
environment
,
ref:
'master'
,
tag:
false
,
sha:
project
.
repository
.
commit
(
'master'
).
sha
}).
execute
dummy_job
=
case
environment
when
'production'
dummy_production_job
when
'staging'
dummy_staging_job
else
raise
ArgumentError
end
CreateDeploymentService
.
new
(
dummy_job
).
execute
end
def
dummy_production_job
@dummy_job
||=
new_dummy_job
(
'production'
)
end
def
dummy_staging_job
@dummy_job
||=
new_dummy_job
(
'staging'
)
end
def
dummy_pipeline
@dummy_pipeline
||=
Ci
::
Pipeline
.
new
(
sha:
project
.
repository
.
commit
(
'master'
).
sha
)
end
def
new_dummy_job
(
environment
)
Ci
::
Build
.
new
(
project:
project
,
user:
user
,
environment:
environment
,
ref:
'master'
,
tag:
false
,
name:
'dummy'
,
pipeline:
dummy_pipeline
)
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