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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
09490fd0
Commit
09490fd0
authored
Nov 15, 2018
by
Shinya Maeda
Committed by
Kamil Trzciński
Nov 15, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ignore environment validation failure
parent
b7cedd91
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
0 deletions
+78
-0
app/models/concerns/deployable.rb
app/models/concerns/deployable.rb
+4
-0
changelogs/unreleased/ignore-environment-validation-failure.yml
...logs/unreleased/ignore-environment-validation-failure.yml
+5
-0
spec/models/concerns/deployable_spec.rb
spec/models/concerns/deployable_spec.rb
+21
-0
spec/services/ci/create_pipeline_service_spec.rb
spec/services/ci/create_pipeline_service_spec.rb
+48
-0
No files found.
app/models/concerns/deployable.rb
View file @
09490fd0
...
...
@@ -13,6 +13,10 @@ module Deployable
name:
expanded_environment_name
)
# If we failed to persist envirionment record by validation error, such as name with invalid character,
# the job will fall back to a non-environment job.
return
unless
environment
.
persisted?
create_deployment!
(
project_id:
environment
.
project_id
,
environment:
environment
,
...
...
changelogs/unreleased/ignore-environment-validation-failure.yml
0 → 100644
View file @
09490fd0
---
title
:
Ignore environment validation failure
merge_request
:
23100
author
:
type
:
fixed
spec/models/concerns/deployable_spec.rb
View file @
09490fd0
...
...
@@ -49,5 +49,26 @@ describe Deployable do
expect
(
environment
).
to
be_nil
end
end
context
'when environment scope contains invalid character'
do
let
(
:job
)
do
create
(
:ci_build
,
name:
'job:deploy-to-test-site'
,
environment:
'$CI_JOB_NAME'
,
options:
{
environment:
{
name:
'$CI_JOB_NAME'
,
url:
'http://staging.example.com/$CI_JOB_NAME'
,
on_stop:
'stop_review_app'
}
})
end
it
'does not create a deployment and environment record'
do
expect
(
deployment
).
to
be_nil
expect
(
environment
).
to
be_nil
end
end
end
end
spec/services/ci/create_pipeline_service_spec.rb
View file @
09490fd0
...
...
@@ -608,5 +608,53 @@ describe Ci::CreatePipelineService do
.
to
eq
variables_attributes
.
map
(
&
:with_indifferent_access
)
end
end
context
'when pipeline has a job with environment'
do
let
(
:pipeline
)
{
execute_service
}
before
do
stub_ci_pipeline_yaml_file
(
YAML
.
dump
(
config
))
end
context
'when environment name is valid'
do
let
(
:config
)
do
{
review_app:
{
script:
'deploy'
,
environment:
{
name:
'review/${CI_COMMIT_REF_NAME}'
,
url:
'http://${CI_COMMIT_REF_SLUG}-staging.example.com'
}
}
}
end
it
'has a job with environment'
do
expect
(
pipeline
.
builds
.
count
).
to
eq
(
1
)
expect
(
pipeline
.
builds
.
first
.
persisted_environment
.
name
).
to
eq
(
'review/master'
)
expect
(
pipeline
.
builds
.
first
.
deployment
).
to
be_created
end
end
context
'when environment name is invalid'
do
let
(
:config
)
do
{
'job:deploy-to-test-site'
:
{
script:
'deploy'
,
environment:
{
name:
'${CI_JOB_NAME}'
,
url:
'https://$APP_URL'
}
}
}
end
it
'has a job without environment'
do
expect
(
pipeline
.
builds
.
count
).
to
eq
(
1
)
expect
(
pipeline
.
builds
.
first
.
persisted_environment
).
to
be_nil
expect
(
pipeline
.
builds
.
first
.
deployment
).
to
be_nil
end
end
end
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