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
8db63b26
Commit
8db63b26
authored
Jun 01, 2017
by
Filip Krakowski
Committed by
Shinya Maeda
Jun 08, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use pipeline.source to determine what triggered a pipeline
parent
fe9b78d6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
21 deletions
+21
-21
README.md
doc/ci/yaml/README.md
+1
-1
gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+16
-16
gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+4
-4
No files found.
doc/ci/yaml/README.md
View file @
8db63b26
...
...
@@ -411,7 +411,7 @@ job:
```
In this example,
`job`
will run only for refs that are tagged, or if a build is
explicitly requested via an API trigger or a
Pipeline Schedule
.
explicitly requested via an API trigger or a
[
Pipeline Schedule
](
../../user/project/pipelines/schedules.md
)
.
```
yaml
job
:
...
...
lib/ci/gitlab_ci_yaml_processor.rb
View file @
8db63b26
...
...
@@ -20,26 +20,26 @@ module Ci
raise
ValidationError
,
e
.
message
end
def
jobs_for_ref
(
ref
,
tag
=
false
,
trigger_request
=
nil
,
pipeline_schedul
e
=
nil
)
def
jobs_for_ref
(
ref
,
tag
=
false
,
sourc
e
=
nil
)
@jobs
.
select
do
|
_
,
job
|
process?
(
job
[
:only
],
job
[
:except
],
ref
,
tag
,
trigger_request
,
pipeline_schedul
e
)
process?
(
job
[
:only
],
job
[
:except
],
ref
,
tag
,
sourc
e
)
end
end
def
jobs_for_stage_and_ref
(
stage
,
ref
,
tag
=
false
,
trigger_request
=
nil
,
pipeline_schedul
e
=
nil
)
jobs_for_ref
(
ref
,
tag
,
trigger_request
,
pipeline_schedul
e
).
select
do
|
_
,
job
|
def
jobs_for_stage_and_ref
(
stage
,
ref
,
tag
=
false
,
sourc
e
=
nil
)
jobs_for_ref
(
ref
,
tag
,
sourc
e
).
select
do
|
_
,
job
|
job
[
:stage
]
==
stage
end
end
def
builds_for_ref
(
ref
,
tag
=
false
,
trigger_request
=
nil
,
pipeline_schedul
e
=
nil
)
jobs_for_ref
(
ref
,
tag
,
trigger_request
,
pipeline_schedul
e
).
map
do
|
name
,
_
|
def
builds_for_ref
(
ref
,
tag
=
false
,
sourc
e
=
nil
)
jobs_for_ref
(
ref
,
tag
,
sourc
e
).
map
do
|
name
,
_
|
build_attributes
(
name
)
end
end
def
builds_for_stage_and_ref
(
stage
,
ref
,
tag
=
false
,
trigger_request
=
nil
,
pipeline_schedul
e
=
nil
)
jobs_for_stage_and_ref
(
stage
,
ref
,
tag
,
trigger_request
,
pipeline_schedul
e
).
map
do
|
name
,
_
|
def
builds_for_stage_and_ref
(
stage
,
ref
,
tag
=
false
,
sourc
e
=
nil
)
jobs_for_stage_and_ref
(
stage
,
ref
,
tag
,
sourc
e
).
map
do
|
name
,
_
|
build_attributes
(
name
)
end
end
...
...
@@ -193,31 +193,31 @@ module Ci
end
end
def
process?
(
only_params
,
except_params
,
ref
,
tag
,
trigger_request
,
pipeline_schedul
e
)
def
process?
(
only_params
,
except_params
,
ref
,
tag
,
sourc
e
)
if
only_params
.
present?
return
false
unless
matching?
(
only_params
,
ref
,
tag
,
trigger_request
,
pipeline_schedul
e
)
return
false
unless
matching?
(
only_params
,
ref
,
tag
,
sourc
e
)
end
if
except_params
.
present?
return
false
if
matching?
(
except_params
,
ref
,
tag
,
trigger_request
,
pipeline_schedul
e
)
return
false
if
matching?
(
except_params
,
ref
,
tag
,
sourc
e
)
end
true
end
def
matching?
(
patterns
,
ref
,
tag
,
trigger_request
,
pipeline_schedul
e
)
def
matching?
(
patterns
,
ref
,
tag
,
sourc
e
)
patterns
.
any?
do
|
pattern
|
match_ref?
(
pattern
,
ref
,
tag
,
trigger_request
,
pipeline_schedul
e
)
match_ref?
(
pattern
,
ref
,
tag
,
sourc
e
)
end
end
def
match_ref?
(
pattern
,
ref
,
tag
,
trigger_request
,
pipeline_schedul
e
)
def
match_ref?
(
pattern
,
ref
,
tag
,
sourc
e
)
pattern
,
path
=
pattern
.
split
(
'@'
,
2
)
return
false
if
path
&&
path
!=
self
.
path
return
true
if
tag
&&
pattern
==
'tags'
return
true
if
!
tag
&&
pattern
==
'branches'
return
true
if
trigger_request
.
present?
&&
pattern
==
'triggers'
return
true
if
pipeline_schedule
.
present?
&&
pattern
==
'schedules'
return
true
if
source
==
'trigger'
&&
pattern
==
'triggers'
return
true
if
source
==
'schedule'
&&
pattern
==
'schedules'
if
pattern
.
first
==
"/"
&&
pattern
.
last
==
"/"
Regexp
.
new
(
pattern
[
1
...-
1
])
=~
ref
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
View file @
8db63b26
...
...
@@ -227,7 +227,7 @@ module Ci
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
,
false
,
true
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
,
false
,
'trigger'
).
size
).
to
eq
(
1
)
end
it
"returns builds if only has a schedules keyword specified and a schedule is provided"
do
...
...
@@ -238,7 +238,7 @@ module Ci
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
,
false
,
false
,
true
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
,
false
,
'schedule'
).
size
).
to
eq
(
1
)
end
it
"does not return builds if only has a triggers keyword specified and no trigger is provided"
do
...
...
@@ -405,7 +405,7 @@ module Ci
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
,
false
,
true
).
size
).
to
eq
(
0
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
,
false
,
'trigger'
).
size
).
to
eq
(
0
)
end
it
"does not return builds if except has a schedules keyword specified and a schedule is provided"
do
...
...
@@ -416,7 +416,7 @@ module Ci
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
,
false
,
false
,
true
).
size
).
to
eq
(
0
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
,
false
,
'schedule'
).
size
).
to
eq
(
0
)
end
it
"returns builds if except has a triggers keyword specified and no trigger is provided"
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