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
7dfb4697
Commit
7dfb4697
authored
3 years ago
by
Allison Browne
Committed by
Fabio Pitino
3 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug where pipelines were tagged a cyclical inappropriately
parent
13166bb2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
5 deletions
+54
-5
app/services/ci/create_downstream_pipeline_service.rb
app/services/ci/create_downstream_pipeline_service.rb
+8
-4
spec/services/ci/create_downstream_pipeline_service_spec.rb
spec/services/ci/create_downstream_pipeline_service_spec.rb
+46
-1
No files found.
app/services/ci/create_downstream_pipeline_service.rb
View file @
7dfb4697
...
...
@@ -19,13 +19,14 @@ module Ci
DuplicateDownstreamPipelineError
.
new
,
bridge_id:
@bridge
.
id
,
project_id:
@bridge
.
project_id
)
return
return
error
(
'Already has a downstream pipeline'
)
end
pipeline_params
=
@bridge
.
downstream_pipeline_params
target_ref
=
pipeline_params
.
dig
(
:target_revision
,
:ref
)
return
unless
ensure_preconditions!
(
target_ref
)
return
error
(
'Pre-conditions not met'
)
unless
ensure_preconditions!
(
target_ref
)
service
=
::
Ci
::
CreatePipelineService
.
new
(
pipeline_params
.
fetch
(
:project
),
...
...
@@ -119,8 +120,11 @@ module Ci
return
false
if
@bridge
.
triggers_child_pipeline?
if
Feature
.
enabled?
(
:ci_drop_cyclical_triggered_pipelines
,
@bridge
.
project
,
default_enabled: :yaml
)
checksums
=
@bridge
.
pipeline
.
base_and_ancestors
.
map
{
|
pipeline
|
config_checksum
(
pipeline
)
}
checksums
.
uniq
.
length
!=
checksums
.
length
pipeline_checksums
=
@bridge
.
pipeline
.
base_and_ancestors
.
filter_map
do
|
pipeline
|
config_checksum
(
pipeline
)
unless
pipeline
.
child?
end
pipeline_checksums
.
uniq
.
length
!=
pipeline_checksums
.
length
end
end
...
...
This diff is collapsed.
Click to expand it.
spec/services/ci/create_downstream_pipeline_service_spec.rb
View file @
7dfb4697
...
...
@@ -136,7 +136,7 @@ RSpec.describe Ci::CreateDownstreamPipelineService, '#execute' do
bridge_id:
bridge
.
id
,
project_id:
bridge
.
project
.
id
)
.
and_call_original
expect
(
Ci
::
CreatePipelineService
).
not_to
receive
(
:new
)
expect
(
service
.
execute
(
bridge
)).
to
be_nil
expect
(
service
.
execute
(
bridge
)).
to
eq
({
message:
"Already has a downstream pipeline"
,
status: :error
})
end
end
...
...
@@ -393,6 +393,51 @@ RSpec.describe Ci::CreateDownstreamPipelineService, '#execute' do
end
end
end
context
'when multi-project pipeline runs from child pipelines bridge job'
do
before
do
stub_ci_pipeline_yaml_file
(
YAML
.
dump
(
rspec:
{
script:
'rspec'
}))
end
# instantiate new service, to clear memoized values from child pipeline run
subject
(
:execute_with_trigger_project_bridge
)
do
described_class
.
new
(
upstream_project
,
user
).
execute
(
trigger_project_bridge
)
end
let!
(
:child_pipeline
)
do
service
.
execute
(
bridge
)
bridge
.
downstream_pipeline
end
let!
(
:trigger_downstream_project
)
do
{
trigger:
{
project:
downstream_project
.
full_path
,
branch:
'feature'
}
}
end
let!
(
:trigger_project_bridge
)
do
create
(
:ci_bridge
,
status: :pending
,
user:
user
,
options:
trigger_downstream_project
,
pipeline:
child_pipeline
)
end
it
'creates a new pipeline'
do
expect
{
execute_with_trigger_project_bridge
}
.
to
change
{
Ci
::
Pipeline
.
count
}.
by
(
1
)
new_pipeline
=
trigger_project_bridge
.
downstream_pipeline
expect
(
new_pipeline
.
child?
).
to
eq
(
false
)
expect
(
new_pipeline
.
triggered_by_pipeline
).
to
eq
child_pipeline
expect
(
trigger_project_bridge
.
reload
).
not_to
be_failed
end
end
end
end
...
...
This diff is collapsed.
Click to expand it.
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