Skip to content

Variable: clone method

Misat11 edited this page May 9, 2020 · 3 revisions

clone-method

This sets clone method!

There are three clone methods:

  1. default, missing - This is the default mehod! It clones just missing variables! Yaml:

    - id: hello
      stack: APPLE
    - clone-method: default
      clone: $hello
      stack: DIRT
      # Final item will be DIRT

    Groovy:

    item('APPLE') {
      id 'hello'
    }
    itemClone('$hello') {
      cloneMethod 'default'
      stack.type 'DIRT'
      // Final item will be DIRT
    }
  2. override - This always clones all variables from parent item!

    Yaml:

    - id: hello
      stack: APPLE
    - clone-method: override
      clone: $hello
      stack: DIRT
      # Final item will be APPLE

    Groovy:

    item('APPLE') {
      id 'hello'
    }
    itemClone('$hello') {
      cloneMethod 'override'
      stack.type 'DIRT'
      // Final item will be APPLE
    }
  3. increment, increment-<method> - This merges two lists (for example items:) and for other variables uses method after dash increment-missing, increment-override

    Yaml:

    - id: hello
      stack: APPLE
      items:
      - stack: ...
      - stack: ...
    - clone-method: increment
      clone: $hello
      stack: DIRT
      # Final item will be DIRT
      items:
      - stack: ...
      - stack: ...
      # Final number of childs will be 4

    Groovy:

    item('APPLE') {
      id 'hello'
    
      item('...')
      item('...')
    }
    itemClone('$hello') {
      cloneMethod 'increment'
      stack.type 'DIRT'
      // Final item will be DIRT
      item('...')
      item('...')
      // Final number of childs will be 4
    }
Clone this wiki locally