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
Boxiang Sun
gitlab-ce
Commits
92d361c8
Commit
92d361c8
authored
Mar 11, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add empty repo check before running AutoDevOps pipeline
parent
afd2d381
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
5 deletions
+37
-5
app/controllers/projects/pipelines_settings_controller.rb
app/controllers/projects/pipelines_settings_controller.rb
+6
-2
spec/controllers/projects/pipelines_settings_controller_spec.rb
...ontrollers/projects/pipelines_settings_controller_spec.rb
+31
-3
No files found.
app/controllers/projects/pipelines_settings_controller.rb
View file @
92d361c8
...
...
@@ -11,9 +11,13 @@ class Projects::PipelinesSettingsController < Projects::ApplicationController
flash
[
:notice
]
=
"Pipelines settings for '
#{
@project
.
name
}
' were successfully updated."
if
service
.
run_auto_devops_pipeline?
if
@project
.
empty_repo?
flash
[
:warning
]
=
"This repository is currently empty. A new Auto DevOps pipeline will be created after a new file has been pushed to a branch."
else
CreatePipelineWorker
.
perform_async
(
project
.
id
,
current_user
.
id
,
project
.
default_branch
,
:web
,
ignore_skip_ci:
true
,
save_on_errors:
false
)
flash
[
:success
]
=
"A new Auto DevOps pipeline has been created, go to <a href=
\"
#{
project_pipelines_path
(
@project
)
}
\"
>Pipelines page</a> for details"
.
html_safe
end
end
redirect_to
project_settings_ci_cd_path
(
@project
)
else
...
...
spec/controllers/projects/pipelines_settings_controller_spec.rb
View file @
92d361c8
...
...
@@ -47,12 +47,40 @@ describe Projects::PipelinesSettingsController do
expect_any_instance_of
(
Projects
::
UpdateService
).
to
receive
(
:run_auto_devops_pipeline?
).
and_return
(
true
)
end
context
'when the project repository is empty'
do
before
do
allow_any_instance_of
(
Project
).
to
receive
(
:empty_repo?
).
and_return
(
true
)
end
it
'sets a warning flash'
do
expect
(
subject
).
to
set_flash
[
:warning
]
end
it
'does not queue a CreatePipelineWorker'
do
expect
(
CreatePipelineWorker
).
not_to
receive
(
:perform_async
).
with
(
project
.
id
,
user
.
id
,
project
.
default_branch
,
:web
,
any_args
)
subject
end
end
context
'when the project repository is not empty'
do
before
do
allow_any_instance_of
(
Project
).
to
receive
(
:empty_repo?
).
and_return
(
false
)
end
it
'sets a success flash'
do
allow
(
CreatePipelineWorker
).
to
receive
(
:perform_async
).
with
(
project
.
id
,
user
.
id
,
project
.
default_branch
,
:web
,
any_args
)
expect
(
subject
).
to
set_flash
[
:success
]
end
it
'queues a CreatePipelineWorker'
do
expect
(
CreatePipelineWorker
).
to
receive
(
:perform_async
).
with
(
project
.
id
,
user
.
id
,
project
.
default_branch
,
:web
,
any_args
)
subject
end
end
end
context
'when run_auto_devops_pipeline is not true'
do
before
do
...
...
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