Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gitlab-ci: allow duplicate cache entries #989

Closed
dirkbolte opened this issue Mar 31, 2020 · 2 comments · Fixed by #1901
Closed

gitlab-ci: allow duplicate cache entries #989

dirkbolte opened this issue Mar 31, 2020 · 2 comments · Fixed by #1901

Comments

@dirkbolte
Copy link
Contributor

I have a gitlab-ci.yml for a monorepo. I used to have multiple gitlab-ci files but merged them into one now. Along with that, I have multiple cache definitions, all with a different anchor.

This works perfectly fine in the runner but the file shows an error (IntelliJ in my case). The definition is:

cache: &global_cache_server
    key: global_cache_key_server
    paths:
        - server/.gradle/
    policy: pull

cache: &global_cache_client
    key: global_cache_key_client
    paths:
        - client/node_modules
    policy: pull

I was about to submit a PR to support that but found no way to define this structure in JSON, nor to allow it in JSON Schema. Any hint on now this can be modelled is appreciated so that I can continue from there.

@GerryFerdinandus
Copy link
Contributor

@dirkbolte
gitlab-ci.yml suport anchor example: https://docs.gitlab.com/ee/ci/yaml/#anchors
But you must use 'dot + unique name'

.cache_1: &global_cache_server
    key: global_cache_key_server
    paths:
        - server/.gradle/
    policy: pull

.cache_2: &global_cache_client
    key: global_cache_key_client
    paths:
        - client/node_modules
    policy: pull

Some where else in the yaml you use the anchor:
<<: * global_cache_server
<<: * global_cache_key_client

The 'dot' is also already implemented in the schema

"patternProperties": {
    "^[.]": {
      "description": "Hidden keys.",
      "anyOf": [
        { "$ref": "#/definitions/job_template" },
        { "description": "Arbitrary YAML anchor." }
      ]
    }

@jcoelho93
Copy link
Contributor

Does it really work? According to Gitlab documentation, multiple cache should be declared like this: https://docs.gitlab.com/ee/ci/caching/index.html#use-multiple-caches

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants