Cloning a step to a new project using the API

Hi -

I’m working on an automated process to “flatten” projects (if a project has 10 components, after the script runs there would be 10 projects with 1 component). Ideally I’d like the process to use the “clone” functionality available at the component level; however I can’t seem to find anything in the api for that specific activity. Am I missing something or is this something that needed to be explicitly scripted. If so, do you have any examples I can use? Thanks.

Greetings ShannonN! We have some example scripts located here. More specifically, the example for creating a step in an existing process is Add a run a script step - Octopus Deploy.

For your scenario, you’ll want to retrieve the Deployment Process for both projects. For step you want to clone, null out the Id property for the step, then add it to the Steps collection of the other project (you may need to null the Id of the Actions as well). The SpaceCloner project contains a good example of cloning process in this file.

Hope this helps!

Regards,

Shawn

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.