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
97dd007b
Commit
97dd007b
authored
Aug 12, 2021
by
Max Woolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for CI_COMMIT_REF_NAME variable in includes
parent
e625c16d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
2 deletions
+13
-2
doc/ci/yaml/index.md
doc/ci/yaml/index.md
+2
-0
lib/gitlab/ci/config.rb
lib/gitlab/ci/config.rb
+10
-1
spec/lib/gitlab/usage_data_counters/ci_template_unique_counter_spec.rb
...ab/usage_data_counters/ci_template_unique_counter_spec.rb
+1
-1
No files found.
doc/ci/yaml/index.md
View file @
97dd007b
...
...
@@ -426,6 +426,8 @@ In `include` sections in your `.gitlab-ci.yml` file, you can use:
-
Project
[
predefined variables
](
../variables/predefined_variables.md
)
.
-
[
Custom instance, group, and project variables
](
../variables/index.md#custom-cicd-variables
)
in GitLab 14.2 and later.
-
`$CI_COMMIT_REF_NAME`
[
predefined variable
](
../variables/predefined_variables.md
)
in GitLab 14.2
and later.
```
yaml
include
:
...
...
lib/gitlab/ci/config.rb
View file @
97dd007b
...
...
@@ -121,17 +121,26 @@ module Gitlab
Gitlab
::
Ci
::
Variables
::
Collection
.
new
.
tap
do
|
variables
|
break
variables
unless
project
# The order of the
next 4
lines is important as priority of CI variables is
# The order of the
following
lines is important as priority of CI variables is
# defined globally within GitLab.
#
# See more detail in the docs: https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
variables
.
concat
(
project
.
predefined_variables
)
variables
.
concat
(
pipeline_predefined_variables
(
ref:
ref
))
variables
.
concat
(
project
.
ci_instance_variables_for
(
ref:
ref
))
variables
.
concat
(
project
.
group
.
ci_variables_for
(
ref
,
project
))
if
project
.
group
variables
.
concat
(
project
.
ci_variables_for
(
ref:
ref
))
end
end
# https://gitlab.com/gitlab-org/gitlab/-/issues/337633 aims to add all predefined variables
# to this list, but only CI_COMMIT_REF_NAME is available right now to support compliance pipelines.
def
pipeline_predefined_variables
(
ref
:)
Gitlab
::
Ci
::
Variables
::
Collection
.
new
.
tap
do
|
v
|
v
.
append
(
key:
'CI_COMMIT_REF_NAME'
,
value:
ref
)
end
end
def
track_and_raise_for_dev_exception
(
error
)
Gitlab
::
ErrorTracking
.
track_and_raise_for_dev_exception
(
error
,
@context
.
sentry_payload
)
end
...
...
spec/lib/gitlab/usage_data_counters/ci_template_unique_counter_spec.rb
View file @
97dd007b
...
...
@@ -60,7 +60,7 @@ RSpec.describe Gitlab::UsageDataCounters::CiTemplateUniqueCounter do
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Config
::
Content
::
AutoDevops
.
new
(
pipeline
,
command
).
content
,
project:
project
,
user:
double
,
sha:
double
sha:
'd310cc759caaa20cd05a9e0983d6017896d9c34c'
).
execute
config_source
=
:auto_devops_source
...
...
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