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?
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
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
I have created a Jython script to copy the phase and then tasks
rSource = "Applications/Folder0e41300abd244964906ceb519ebdf5f9/Releasead3f0208aa8e4c3b8619a890bb35c194" rDest = "Applications/Folder0e41300abd244964906ceb519ebdf5f9/Release3ef970f6b89447fa9c17b48e84ca5c9d" p=phaseApi.searchPhasesByTitle("Phase1", rSource) phasetocopy = phaseApi.getPhase(str(p)) addnewphasedest = phaseApi.addPhase(rDest, phasetocopy) for task in phasetocopy.tasks: taskApi.addTask(addnewphasedest.id, task) print("New phase ID is: %s" % addnewphasedest.id) print("%s tasks copied" % len(phasetocopy.tasks))
I stumbled across this api package the other day and wondered if it could be used for this purpose.