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
16084ee9
Commit
16084ee9
authored
Jul 31, 2019
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port changes from EE
Ports changes from
https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/12343
parent
bce8b66d
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
65 additions
and
9 deletions
+65
-9
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+4
-0
doc/ci/multi_project_pipelines.md
doc/ci/multi_project_pipelines.md
+15
-0
lib/gitlab/ci/pipeline/seed/build.rb
lib/gitlab/ci/pipeline/seed/build.rb
+4
-1
lib/gitlab/ci/yaml_processor.rb
lib/gitlab/ci/yaml_processor.rb
+2
-1
spec/factories/ci/bridge.rb
spec/factories/ci/bridge.rb
+8
-1
spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
+20
-4
spec/lib/gitlab/ci/yaml_processor_spec.rb
spec/lib/gitlab/ci/yaml_processor_spec.rb
+4
-1
spec/models/ci/bridge_spec.rb
spec/models/ci/bridge_spec.rb
+1
-1
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+7
-0
No files found.
app/models/ci/pipeline.rb
View file @
16084ee9
...
...
@@ -328,6 +328,10 @@ module Ci
config_sources
.
values_at
(
:repository_source
,
:auto_devops_source
,
:unknown_source
)
end
def
self
.
bridgeable_statuses
::
Ci
::
Pipeline
::
AVAILABLE_STATUSES
-
%w[created preparing pending]
end
def
stages_count
statuses
.
select
(
:stage
).
distinct
.
count
end
...
...
doc/ci/multi_project_pipelines.md
View file @
16084ee9
...
...
@@ -176,6 +176,21 @@ Upstream pipelines take precedence over downstream ones. If there are two
variables with the same name defined in both upstream and downstream projects,
the ones defined in the upstream project will take precedence.
### Mirroring status from upstream pipeline
You can mirror the pipeline status from an upstream pipeline to a bridge job by
using the
`needs:pipeline`
keyword. The latest pipeline status from master is
replicated to the bridge job.
Example:
```
yaml
upstream_bridge
:
stage
:
test
needs
:
pipeline
:
other/project
```
### Limitations
Because bridge jobs are a little different to regular jobs, it is not
...
...
lib/gitlab/ci/pipeline/seed/build.rb
View file @
16084ee9
...
...
@@ -45,7 +45,10 @@ module Gitlab
end
def
bridge?
@attributes
.
to_h
.
dig
(
:options
,
:trigger
).
present?
attributes_hash
=
@attributes
.
to_h
attributes_hash
.
dig
(
:options
,
:trigger
).
present?
||
(
attributes_hash
.
dig
(
:options
,
:bridge_needs
).
instance_of?
(
Hash
)
&&
attributes_hash
.
dig
(
:options
,
:bridge_needs
,
:pipeline
).
present?
)
end
def
all_of_only?
...
...
lib/gitlab/ci/yaml_processor.rb
View file @
16084ee9
...
...
@@ -55,7 +55,8 @@ module Gitlab
parallel:
job
[
:parallel
],
instance:
job
[
:instance
],
start_in:
job
[
:start_in
],
trigger:
job
[
:trigger
]
trigger:
job
[
:trigger
],
bridge_needs:
job
[
:needs
]
}.
compact
}.
compact
end
...
...
spec/factories/ci/bridge.rb
View file @
16084ee9
...
...
@@ -8,7 +8,7 @@ FactoryBot.define do
ref
'master'
tag
false
created_at
'Di 29. Okt 09:50:00 CET 2013'
status
:
success
status
:
created
pipeline
factory: :ci_pipeline
...
...
@@ -17,6 +17,7 @@ FactoryBot.define do
end
transient
{
downstream
nil
}
transient
{
upstream
nil
}
after
(
:build
)
do
|
bridge
,
evaluator
|
bridge
.
project
||=
bridge
.
pipeline
.
project
...
...
@@ -26,6 +27,12 @@ FactoryBot.define do
trigger:
{
project:
evaluator
.
downstream
.
full_path
}
)
end
if
evaluator
.
upstream
.
present?
bridge
.
options
=
bridge
.
options
.
to_h
.
merge
(
bridge_needs:
{
pipeline:
evaluator
.
upstream
.
full_path
}
)
end
end
end
end
spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
View file @
16084ee9
...
...
@@ -20,20 +20,36 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
describe
'#bridge?'
do
subject
{
seed_build
.
bridge?
}
context
'when job is a bridge'
do
context
'when job is a
downstream
bridge'
do
let
(
:attributes
)
do
{
name:
'rspec'
,
ref:
'master'
,
options:
{
trigger:
'my/project'
}
}
end
it
{
is_expected
.
to
be_truthy
}
context
'when trigger definition is empty'
do
let
(
:attributes
)
do
{
name:
'rspec'
,
ref:
'master'
,
options:
{
trigger:
''
}
}
end
it
{
is_expected
.
to
be_falsey
}
end
end
context
'when
trigger definition is empty
'
do
context
'when
job is an upstream bridge
'
do
let
(
:attributes
)
do
{
name:
'rspec'
,
ref:
'master'
,
options:
{
trigger:
''
}
}
{
name:
'rspec'
,
ref:
'master'
,
options:
{
bridge_needs:
{
pipeline:
'my/project'
}
}
}
end
it
{
is_expected
.
to
be_falsey
}
it
{
is_expected
.
to
be_truthy
}
context
'when upstream definition is empty'
do
let
(
:attributes
)
do
{
name:
'rspec'
,
ref:
'master'
,
options:
{
bridge_needs:
{
pipeline:
''
}
}
}
end
it
{
is_expected
.
to
be_falsey
}
end
end
context
'when job is not a bridge'
do
...
...
spec/lib/gitlab/ci/yaml_processor_spec.rb
View file @
16084ee9
...
...
@@ -1153,7 +1153,10 @@ module Gitlab
stage_idx:
1
,
name:
"test1"
,
options:
{
script:
[
"test"
]
script:
[
"test"
],
# This does not make sense, there is a follow-up:
# https://gitlab.com/gitlab-org/gitlab-ce/issues/65569
bridge_needs:
%w[build1 build2]
},
needs_attributes:
[
{
name:
"build1"
},
...
...
spec/models/ci/bridge_spec.rb
View file @
16084ee9
...
...
@@ -23,7 +23,7 @@ describe Ci::Bridge do
let
(
:status
)
{
bridge
.
detailed_status
(
user
)
}
it
'returns detailed status object'
do
expect
(
status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Success
expect
(
status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Created
end
end
...
...
spec/models/ci/pipeline_spec.rb
View file @
16084ee9
...
...
@@ -1929,6 +1929,13 @@ describe Ci::Pipeline, :mailer do
it
{
is_expected
.
to
be_an
(
Array
)
}
end
describe
'.bridgeable_statuses'
do
subject
{
described_class
.
bridgeable_statuses
}
it
{
is_expected
.
to
be_an
(
Array
)
}
it
{
is_expected
.
not_to
include
(
'created'
,
'preparing'
,
'pending'
)
}
end
describe
'#status'
do
let
(
:build
)
do
create
(
:ci_build
,
:created
,
pipeline:
pipeline
,
name:
'test'
)
...
...
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