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
d2e19edc
Commit
d2e19edc
authored
Jun 04, 2021
by
Marcel Amirault
Committed by
Shinya Maeda
Jun 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply 3 suggestion(s) to 1 file(s)
parent
0c063e8f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
8 deletions
+15
-8
doc/development/cicd/templates.md
doc/development/cicd/templates.md
+11
-7
lib/gitlab/template/gitlab_ci_yml_template.rb
lib/gitlab/template/gitlab_ci_yml_template.rb
+2
-0
spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb
spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb
+2
-1
No files found.
doc/development/cicd/templates.md
View file @
d2e19edc
...
...
@@ -309,19 +309,23 @@ include:
### Use a feature flag to rollout the latest template
At a GitLab major version update, we should renew
[
stable templates
](
#stable-version
)
by the corresponding
[
latest templates
](
#latest-version
)
,
but in some cases, you'd want to gauge the impact at first, so that we can be
more confident that the change wouldn't require revert/rollback on production.
At a major version, like 13.0 or 14.0,
[
stable templates
](
#stable-version
)
must be
updated with their corresponding
[
latest template versions
](
#latest-version
)
.
It may be hard to gauge the impact of this change, so use the
`redirect_to_latest_template_<name>`
feature flag to test the impact on a subset of users. Using a feature flag can help
reduce the risk of reverts or rollbacks on production.
To do so, you can use the feature flag, named
`redirect_to_latest_template_<name>`
.
For example, you can redirect to the latest template in 25% of projects on
`gitlab.com`
, by the following chatops command
:
For example, to redirect the stable
`Jobs/Deploy`
template to its latest template in 25% of
projects on
`gitlab.com`
:
```
shell
/chatops run feature
set
redirect_to_latest_template_jobs_deploy 25
--actors
```
Once you're confident on the latest template, you should renew the stable template by the latest content,
remove the latest template and remove the corresponding feature flag.
After you're confident the latest template can be moved to stable:
1.
Update the stable template with the content of the latest version.
1.
Remove the corresponding feature flag.
### Further reading
...
...
lib/gitlab/template/gitlab_ci_yml_template.rb
View file @
d2e19edc
...
...
@@ -18,6 +18,7 @@ module Gitlab
end
class
<<
self
extend
::
Gitlab
::
Utils
::
Override
include
Gitlab
::
Utils
::
StrongMemoize
def
extension
...
...
@@ -63,6 +64,7 @@ module Gitlab
)
end
override
:find
def
find
(
key
,
project
=
nil
)
if
try_redirect_to_latest?
(
key
,
project
)
key
+=
'.latest'
...
...
spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb
View file @
d2e19edc
...
...
@@ -23,6 +23,7 @@ RSpec.describe Gitlab::Template::GitlabCiYmlTemplate do
describe
'.find'
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:other_project
)
{
create
(
:project
)
}
described_class
::
TEMPLATES_WITH_LATEST_VERSION
.
keys
.
each
do
|
key
|
it
"finds the latest template for
#{
key
}
"
do
...
...
@@ -57,7 +58,7 @@ RSpec.describe Gitlab::Template::GitlabCiYmlTemplate do
context
'when `redirect_to_latest_template` feature flag is enabled on the other project'
do
before
do
stub_feature_flags
(
"redirect_to_latest_template_
#{
key
.
underscore
.
tr
(
'/'
,
'_'
)
}
"
.
to_sym
=>
create
(
:project
)
)
stub_feature_flags
(
"redirect_to_latest_template_
#{
key
.
underscore
.
tr
(
'/'
,
'_'
)
}
"
.
to_sym
=>
other_project
)
end
it
"finds the stable template for
#{
key
}
"
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