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
634bb820
Commit
634bb820
authored
Feb 21, 2022
by
Marius Bobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor pipeline schedule variables
Changelog: other
parent
15e1fb16
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletion
+27
-1
lib/gitlab/ci/variables/builder.rb
lib/gitlab/ci/variables/builder.rb
+13
-1
spec/lib/gitlab/ci/variables/builder_spec.rb
spec/lib/gitlab/ci/variables/builder_spec.rb
+14
-0
No files found.
lib/gitlab/ci/variables/builder.rb
View file @
634bb820
...
...
@@ -28,7 +28,7 @@ module Gitlab
variables
.
concat
(
secret_project_variables
(
environment:
environment
))
variables
.
concat
(
job
.
trigger_request
.
user_variables
)
if
job
.
trigger_request
variables
.
concat
(
pipeline
.
variables
)
variables
.
concat
(
pipeline
.
pipeline_schedule
.
job_variables
)
if
pipeline
.
pipeline_schedule
variables
.
concat
(
pipeline
_schedule_variables
)
end
end
...
...
@@ -120,6 +120,18 @@ module Gitlab
end
end
def
pipeline_schedule_variables
strong_memoize
(
:pipeline_schedule_variables
)
do
variables
=
if
pipeline
.
pipeline_schedule
pipeline
.
pipeline_schedule
.
job_variables
else
[]
end
Gitlab
::
Ci
::
Variables
::
Collection
.
new
(
variables
)
end
end
def
ci_node_total_value
(
job
)
parallel
=
job
.
options
&
.
dig
(
:parallel
)
parallel
=
parallel
.
dig
(
:total
)
if
parallel
.
is_a?
(
Hash
)
...
...
spec/lib/gitlab/ci/variables/builder_spec.rb
View file @
634bb820
...
...
@@ -199,6 +199,20 @@ RSpec.describe Gitlab::Ci::Variables::Builder do
'O'
=>
'15'
,
'P'
=>
'15'
)
end
end
context
'with schedule variables'
do
let_it_be
(
:schedule
)
{
create
(
:ci_pipeline_schedule
,
project:
project
)
}
let_it_be
(
:schedule_variable
)
{
create
(
:ci_pipeline_schedule_variable
,
pipeline_schedule:
schedule
)
}
before
do
pipeline
.
update!
(
pipeline_schedule_id:
schedule
.
id
)
end
it
'includes schedule variables'
do
expect
(
subject
.
to_runner_variables
)
.
to
include
(
a_hash_including
(
key:
schedule_variable
.
key
,
value:
schedule_variable
.
value
))
end
end
end
describe
'#user_variables'
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