There are three ways to generate DSL scripts, based on your needs:
Through the DSL IDE: a general purpose DSL editor
Through the object editor: best for Single objects
Through the Export DSL catalog item: best for object hierarchies
You can export any object such as a pipeline, application or microservice, environments, release, and so on, to a DSL file to represent its definition as code. You can then store the file in a source code repository of your choice.
The DSL-based representation of any object lets you recreate that state of the object at any point. For example, let’s say you have a pipeline named Heatclinic pipeline DSL and you want to be able to recreate its current state at any point in the future. Using the DSL Export feature, you can export the current definition for this pipeline as code to a DSL file.
Then check this version of the DSL file into your source code repository. This DSL file has all the details of the pipeline stages, gates, and tasks. It also retains references to the snapshots used for deployments in various stages of this pipeline. Snapshots capture references to the exact versions of the artifacts, configurations, and so on. This lets you recreate this exact state of the pipeline at any point in the future for various scenarios. To do so, you check out that DSL file and evaluate the DSL using either the
evalDsl API or the DSL editor. Evaluating this DSL recreates the pipeline as it was when the DSL file was created.
While this example showcases pipeline objects, the DSL export functionality is available from most CloudBees CD objects.
This method is limited to the following object types: Applications, microservices, environments, master components, environment and resource templates, reports, releases, and pipelines.
ectool generateDsl <path> [optionals] API command to generate an XML file representing the contents of a CloudBees CD object. See the generateDsl command for full syntax and examples.
To generate DSL scripts representing the contents of an entire CloudBees CD object structure including all nested objects, parameters, and custom properties, use the export DSL catalog item available with the CloudBees CD UI. This method is available for all CloudBees CD object types.
The scripts are organized in a file structure suitable for importing back into the object structure. In this way, you can use the corresponding Import DSL service catalog item to easily create new objects based on the existing object structure or to override the original object structure.