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
ac9d7929
Commit
ac9d7929
authored
Mar 07, 2017
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'set-default-cache-key-for-jobs' into 'master'
Set default cache key to 'default' for jobs Closes #22419 See merge request !9666
parents
74bfa890
23198320
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
60 additions
and
7 deletions
+60
-7
set-default-cache-key-for-jobs.yml
changelogs/unreleased/set-default-cache-key-for-jobs.yml
+4
-0
README.md
doc/ci/yaml/README.md
+13
-4
cache.rb
lib/gitlab/ci/config/entry/cache.rb
+6
-0
key.rb
lib/gitlab/ci/config/entry/key.rb
+4
-0
node.rb
lib/gitlab/ci/config/entry/node.rb
+6
-0
undefined.rb
lib/gitlab/ci/config/entry/undefined.rb
+4
-0
cache_spec.rb
spec/lib/gitlab/ci/config/entry/cache_spec.rb
+14
-0
factory_spec.rb
spec/lib/gitlab/ci/config/entry/factory_spec.rb
+2
-2
global_spec.rb
spec/lib/gitlab/ci/config/entry/global_spec.rb
+1
-1
key_spec.rb
spec/lib/gitlab/ci/config/entry/key_spec.rb
+6
-0
No files found.
changelogs/unreleased/set-default-cache-key-for-jobs.yml
0 → 100644
View file @
ac9d7929
---
title
:
Set default cache key to "default" for jobs
merge_request
:
9666
author
:
doc/ci/yaml/README.md
View file @
ac9d7929
...
...
@@ -166,10 +166,11 @@ which can be set in GitLab's UI.
cached between jobs. You can only use paths that are within the project
workspace.
**By default the caching is enabled per-job and per-branch.**
**
By default caching is enabled and shared between pipelines and jobs,
starting from GitLab 9.0
**
If
`cache`
is defined outside the scope of
the
jobs, it means it is set
globally and all jobs will use
its
definition.
If
`cache`
is defined outside the scope of jobs, it means it is set
globally and all jobs will use
that
definition.
Cache all files in
`binaries`
and
`.config`
:
...
...
@@ -202,7 +203,7 @@ rspec:
-
binaries/
```
Locally defined cache over
writ
es globally defined options. The following
`rspec`
Locally defined cache over
rid
es globally defined options. The following
`rspec`
job will cache only
`binaries/`
:
```
yaml
...
...
@@ -213,10 +214,15 @@ cache:
rspec
:
script
:
test
cache
:
key
:
rspec
paths
:
-
binaries/
```
Note that since cache is shared between jobs, if you're using different
paths for different jobs, you should also set a different
**cache:key**
otherwise cache content can be overwritten.
The cache is provided on a best-effort basis, so don't expect that the cache
will be always present. For implementation details, please check GitLab Runner.
...
...
@@ -233,6 +239,9 @@ different jobs or even different branches.
The
`cache:key`
variable can use any of the
[
predefined variables
](
../variables/README.md
)
.
The default key is
**default**
across the project, therefore everything is
shared between each pipelines and jobs by default, starting from GitLab 9.0.
---
**Example configurations**
...
...
lib/gitlab/ci/config/entry/cache.rb
View file @
ac9d7929
...
...
@@ -22,6 +22,12 @@ module Gitlab
entry
:paths
,
Entry
::
Paths
,
description:
'Specify which paths should be cached across builds.'
helpers
:key
def
value
super
.
merge
(
key:
key_value
)
end
end
end
end
...
...
lib/gitlab/ci/config/entry/key.rb
View file @
ac9d7929
...
...
@@ -11,6 +11,10 @@ module Gitlab
validations
do
validates
:config
,
key:
true
end
def
self
.
default
'default'
end
end
end
end
...
...
lib/gitlab/ci/config/entry/node.rb
View file @
ac9d7929
...
...
@@ -70,6 +70,12 @@ module Gitlab
true
end
def
inspect
val
=
leaf?
?
config
:
descendants
unspecified
=
specified?
?
''
:
'(unspecified) '
"#<
#{
self
.
class
.
name
}
#{
unspecified
}
{
#{
key
}
:
#{
val
.
inspect
}
}>"
end
def
self
.
default
end
...
...
lib/gitlab/ci/config/entry/undefined.rb
View file @
ac9d7929
...
...
@@ -29,6 +29,10 @@ module Gitlab
def
relevant?
false
end
def
inspect
"#<
#{
self
.
class
.
name
}
>"
end
end
end
end
...
...
spec/lib/gitlab/ci/config/entry/cache_spec.rb
View file @
ac9d7929
...
...
@@ -24,6 +24,20 @@ describe Gitlab::Ci::Config::Entry::Cache do
expect
(
entry
).
to
be_valid
end
end
context
'when key is missing'
do
let
(
:config
)
do
{
untracked:
true
,
paths:
[
'some/path/'
]
}
end
describe
'#value'
do
it
'sets key with the default'
do
expect
(
entry
.
value
[
:key
])
.
to
eq
(
Gitlab
::
Ci
::
Config
::
Entry
::
Key
.
default
)
end
end
end
end
context
'when entry value is not correct'
do
...
...
spec/lib/gitlab/ci/config/entry/factory_spec.rb
View file @
ac9d7929
...
...
@@ -60,13 +60,13 @@ describe Gitlab::Ci::Config::Entry::Factory do
end
context
'when creating entry with nil value'
do
it
'creates an un
defin
ed entry'
do
it
'creates an un
specifi
ed entry'
do
entry
=
factory
.
value
(
nil
)
.
create!
expect
(
entry
)
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Entry
::
Un
specified
.
not_to
be_
specified
end
end
...
...
spec/lib/gitlab/ci/config/entry/global_spec.rb
View file @
ac9d7929
...
...
@@ -188,7 +188,7 @@ describe Gitlab::Ci::Config::Entry::Global do
it
'contains unspecified nodes'
do
expect
(
global
.
descendants
.
first
)
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Entry
::
Un
specified
.
not_to
be_
specified
end
end
...
...
spec/lib/gitlab/ci/config/entry/key_spec.rb
View file @
ac9d7929
...
...
@@ -31,4 +31,10 @@ describe Gitlab::Ci::Config::Entry::Key do
end
end
end
describe
'.default'
do
it
'returns default key'
do
expect
(
described_class
.
default
).
to
eq
'default'
end
end
end
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