MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

Cloudbees CD RO Tutorials: DSL

CloudBees CD/RO DSL is a Groovy-based language for defining projects, procedures, steps, pipelines and properties as code. You run these scripts on the server with ectool evalDsl. This page builds on the commands above with a complete working script, the login step that has to come first, parameterised scripts, exporting existing objects to DSL, and fixes for the errors people hit most often.

URL – https://docs.cloudbees.com/docs/cloudbees-cd-api/latest/flow-api/dslabout


From the command-line interface 
Use the evalDsl command to evaluate and run a DSL script. See the command evalDsl for a list of the supported arguments. 
 
These ectool examples show how to evaluate a DSL script. 
 
When specifying the DSL text, enter ectool evalDsl <dsl>. For example: 
 
$ ectool evalDsl "project 'My WAR file' " 

When specifying the path to the DSL script on the client, enter evalDsl --dslFile <dslFile>. For example: 
 
$ ectool evalDsl --dslFile c:/dslScripts/myWarFile.dsl
$ ectool evalDsl --dslFile c:/dslScripts/myWarFile.dslCode language: JavaScript (javascript)

  136  ectool evalDsl dsl --describe 1
  138  ectool evalDsl getProcedure --describe 1
  
  141  ectool evalDsl --dslFile pro.groovy
  148  ectool evalDsl --dslFile pro.groovy
  149  vi pro.groovy
  150  ectool evalDsl --dslFile pro.groovyCode language: CSS (css)


What the CloudBees CD/RO DSL is

CloudBees CD/RO (previously CloudBees Flow and ElectricFlow) stores every object in a hierarchy: projects contain procedures, procedures contain steps, and almost any object can carry properties. The DSL is a Groovy syntax that describes this hierarchy. Each nested block maps to one object type, such as project, procedure, step, pipeline, environment or property.

DSL scripts are declarative and safe to re-run. If an object named in the script already exists, evalDsl updates it. If it does not exist, evalDsl creates it. Because of this, a DSL file kept in Git can serve as the source of truth for your release automation, and you can apply it again after every change.

Note: The script is evaluated on the CloudBees CD/RO server, not on your workstation. --dslFile reads the file from the client machine and sends its contents to the server. Any file paths inside the script refer to the server's file system.

Prerequisites and logging in

The example above leaves out one step: ectool needs an authenticated session before evalDsl will work. Install the CloudBees CD/RO command-line tools on your machine (or use a server or agent host that already has them), then log in.

# Log in once; ectool stores a session for later commands
ectool --server cd.example.com login admin
# You are prompted for the password if you leave it off the command line

# Confirm the session works
ectool getServerInfoCode language: PHP (php)

Putting the password on the command line saves it in your shell history. Let ectool prompt for it instead. In CI jobs, pass it in from a secrets store.

A complete first DSL script

The history above runs pro.groovy but never shows its contents. Here is a minimal, complete version that creates a project with a property, a procedure, a parameter and two steps.

// pro.groovy
project 'Hello Project', {
  description = 'Created and maintained with DSL'

  property 'appVersion', value: '1.0.0'

  procedure 'Hello Procedure', {
    description = 'Prints a greeting'

    formalParameter 'greeting', defaultValue: 'Hello', required: '1', type: 'entry'

    step 'Say hello', {
      // Single quotes stop Groovy from treating $[...] as a Groovy variable
      command = 'echo "$[greeting] from version $[/myProject/appVersion]"'
    }

    step 'Show host', {
      command = 'hostname'
    }
  }
}Code language: JavaScript (javascript)

$[greeting] and $[/myProject/appVersion] use CloudBees CD/RO property reference syntax. The server expands them when the step runs, not when the DSL is evaluated. Apply the script and then check the result:

ectool evalDsl --dslFile pro.groovy

# Verify the objects exist
ectool getProject "Hello Project"
ectool getProcedure "Hello Project" "Hello Procedure"

# Run the procedure and get a job ID back
ectool runProcedure "Hello Project" --procedureName "Hello Procedure" --actualParameter greeting=HiCode language: PHP (php)

evalDsl prints an XML response that describes the object returned by the last statement in the script, which here is the project. Edit the file, for example by changing appVersion or adding a step, and run the same command again. The project is updated in place, so this is the vi pro.groovy and re-run loop shown in the history above.

Passing parameters to a DSL script

Hard-coded names make a script hard to reuse. evalDsl accepts a JSON object through --parameters, or through --parametersFile if the JSON is in a file. Inside the script, the values are available through the args variable.

// app.groovy
def projName = args.projectName
def env      = args.envName ?: 'dev'

project projName, {
  property 'targetEnv', value: env
}Code language: JavaScript (javascript)
ectool evalDsl --dslFile app.groovy \
  --parameters '{"projectName":"Payments","envName":"qa"}'Code language: JavaScript (javascript)

Note: On Windows cmd.exe, wrap the JSON in double quotes and escape the inner quotes, or put the JSON in a file and use --parametersFile to avoid quoting trouble.

Discovering DSL methods with –describe

The --describe 1 commands in the history above are the built-in reference. They are the quickest way to find the exact method names and arguments your server version supports.

CommandWhat it returns
ectool evalDsl dsl --describe 1A list of the DSL methods available on the server
ectool evalDsl getProcedure --describe 1The arguments and usage for a single method, here getProcedure
ectool evalDsl "getProjects()"Runs an API call as DSL and returns the result

Any API command available in ectool, such as getProject or runProcedure, can also be called from inside a DSL script. This lets a script query the server and act on what it finds.

Exporting existing objects as DSL

If your projects were built in the web UI, you don't have to write their DSL by hand. generateDsl produces DSL for any object path. Save the output to a file, commit it to version control, and apply it from there from then on.

ectool generateDsl "/projects/Hello Project" --suppressDefaults 1 --suppressNulls 1 > hello-project.groovy

# Review, commit, then apply on another server
ectool --server cd-staging.example.com login admin
ectool evalDsl --dslFile hello-project.groovyCode language: PHP (php)

Suppressing defaults and null values leaves out every attribute that is unset or at its default value. This makes the output much shorter and keeps diffs readable.

Common errors and fixes

SymptomLikely causeFix
Error about missing or expired credentials or sessionNo ectool login, or the session timed outRun ectool --server <host> login <user> again
illegal string body character after dollar sign$[...] was placed inside a double-quoted Groovy stringUse single quotes for commands that contain $[...], or escape the dollar sign as \$
NoSuchObject or object not foundThe script refers to a project, procedure or resource that doesn't exist, or the name is misspelledCheck names with getProject or getProcedure. Names are matched exactly, including spaces
Access denied or permission errorYour user lacks modify rights on the object or its parentAsk an administrator to grant the right ACL entries, or run the script as a service account
File not found with --dslFileWrong path on the client, or backslashes not escaped in a Windows pathUse forward slashes (c:/dslScripts/file.groovy) or quote the path

Corrections to the example above

  • The --dslFile command is printed twice in a row. Running it once is enough. A second run only re-applies the same definition.
  • The second code block is pasted shell history, and the leading numbers (136, 138, 141 and so on) are line numbers, not part of the commands. Remove them before running anything.
  • The original never logs in. Run ectool --server <host> login <user> before any evalDsl command.
  • The contents of pro.groovy are not shown. The complete script in the section above shows what such a file looks like.

Best practices

  • Keep one DSL file per project or pipeline in Git, and apply it from CI so the server always matches the repository.
  • Use --parameters for anything that differs between environments, instead of copying a script for each one.
  • Never put passwords or tokens in DSL files. Store them as credentials in CloudBees CD/RO and refer to them by name.
  • Test changes on a non-production server first. evalDsl changes objects immediately, and there is no dry run.
  • Run generateDsl regularly to catch drift between objects edited in the UI and the version in Git.

Frequently asked questions

What language does CloudBees CD/RO DSL use?

It is based on Groovy, so you can use normal Groovy variables, loops, conditionals and closures around the DSL blocks such as project, procedure and step.

Does running evalDsl twice create duplicate objects?

No. Objects are matched by name. Running the same script again updates the existing objects instead of creating copies.

How do I convert an existing CloudBees CD/RO project to DSL?

Run ectool generateDsl "/projects/<Project Name>" and redirect the output to a .groovy file. Adding --suppressDefaults 1 --suppressNulls 1 makes the output shorter.

How do I pass variables into a DSL script?

Use --parameters with a JSON object, or --parametersFile with a JSON file. Then read the values in the script through args, for example args.projectName.

Why does my step command fail to compile when it contains $[…]?

In a double-quoted Groovy string, $ starts a Groovy interpolation. Wrap commands that contain CloudBees property references in single quotes so the server expands them when the step runs.

Related tutorials

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

Jenkins Tutorials: Meaning of $class in scripted pipeline

In a Jenkins Pipeline, $class is a special map key that tells Jenkins which plugin or core class to create when a step or property accepts more…

Read More

Cloudbees CD RO Tutorials: ectool tools

ectool is the command-line client for CloudBees CD/RO (formerly CloudBees Flow and ElectricFlow). Each subcommand sends one API request to the CD/RO server. This page covers installing…

Read More

Groovy Tutorials: How to write comments in Groovy?

Groovy has three kinds of comment that it shares with Java: single-line comments with //, block comments between /* and */, and GroovyDoc comments between /** and…

Read More

Automating Jenkins Job Configuration: Job DSL, Multibranch, Job Generator, and JJB

Manually creating many Jenkins jobs is slow and error-prone. This guide compares the main automation options and shows practical jobs-as-code examples for repeatable setup.

Read More

Gradle Training Curriculum: Hands-On Learning Path for Build and DevOps Engineers

A revised, practical Gradle training guide based on the original course outline. It maps the agenda to hands-on labs, CI workflow, and team-ready build practices.

Read More

Deploying Java EE on Amazon EC2 with EC2Deploy: Workflow, Script, and Modern Lessons

This revised guide breaks down the original EC2Deploy approach for provisioning EC2 instances, deploying Java EE apps, and running JMeter tests. It also maps the same deployment pattern to modern DevOps practices.

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x