How to copy a task from one template to another?

#1

I have created a snippets folder and added various examples for teams to use as reference. How can one copy a task from my template to his template in another folder?

#2

That’s currently not supported. The only thing that springs to mind is to use the xl client to export the templates, edit the yaml and then import them again with xl apply

https://docs.xebialabs.com/v.9.5/xl-release/concept/get-started-with-devops-as-code/

#3

In addition to the “DevOps as code” approach described above: If your task snippets are bigger building blocks than just single tasks, like a squence of tasks etc you want to reuse, you could also use this as a separate release template and call it from another templae: https://docs.xebialabs.com/v.9.5/xl-release/how-to/start-a-release-from-another-release/#master-release-with-subreleases.
You can even use variables to tranfer information or messages from master to sub release.
Of course, you can combine both approaches, so you can create master/sub releases in UI or in code:

tasks:
    - name: Sub release
      type: xlrelease.CreateReleaseTask
      newReleaseTitle: My subrelease
      templateId: My template
      folderId: My folder/Subfolder
      templateVariables:
      - key: version
        value: 1.0
        type: xlrelease.StringVariable

See more examples here: https://docs.xebialabs.com/v.9.5/xl-release/concept/yaml-snippets-reference/#xl-release-yaml-snippets

1 Like