REST Support in CloudBees Flow and ElectricCommander 5.2

Written by: Electric Bee

3 min read

Stay connected

One of the enduring strengths of ElectricCommander and CloudBees Flow is the full API support: anything you can do in the product's UI you can also do from the command line using ectool, or using other tools or systems with our Perl and Java API bindings. However, not everyone in the world wants to learn Perl or Java (shocking, I know). So, one of the most frequently requested features for ElectricCommander has been to provide a REST API, making it easier to consume the Commander API in the language of your choice. Starting with version 5.2, CloudBees Flow and ElectricCommander server API are fully REST-enabled and REST is a first-class citizen going forward. For existing customers that are too impatient to read through the rest of this blog (pun intended) - the REST API is exposed on your https://localhost:8443/rest/v1.0  - Have at it. We have used the excellent Swagger-UI to document the API and make it more discoverable. swagger

To see that, visit https://localhost:8443/rest/doc/v1.0 (actually - for everything to work correctly, security-wise - you'll want to use the fully-qualified hostname of your Commander server when using Swagger).

Sample Code:

Following are a few simple examples, all using curl to do the heavy lifting. For brevity, I'm leaving out the authentication options, but you could use basic authentication by passing --basic -u user:password   , for example. Create a project, passing arguments as query parameters:

curl https://localhost:8443/rest/v1.0/projects?projectName=MyProject -d ''

Fetch a project by name:

curl https://localhost:8443/rest/v1.0/projects/MyProject

Simple parameters can be included either as query string parameters or as part of the JSON payload. Create a procedure with the description passed as a query parameter (remember to escape the "&" if you use sh):

curl https://localhost:8443/rest/v1.0/projects/MyProject/procedures?procedureName=procedure1&description=MyDescription -d ''

or, pass the parameters in the JSON body:

curl https://localhost:8443/rest/v1.0/projects/MyProject/procedures -d '{"procedureName":"procedure2","description":"My description"}'

Fetch the procedures we just created:

curl https://localhost:8443/rest/v1.0/projects/MyProject/procedures

For a more realistic example , one of our excellent professional services engineers (thanks, Robert!) created a JQuery-based app which you can find at https://github.com/electriccommunity/electriccommander/tree/master/CommanderREST

robert-rest-api

You can also check out the RESTful API documentation for CloudBees Flow and ElectricCommander 


See it in action:

code-api

Join us on November 12, at 10am PST for a live demo of the REST API. The technical webinar will highlight key features and functionality and cover common use cases, including:  

  • How to access the native REST interface
  • How to use REST to create new jobs, kick off existing jobs, or report on finished jobs
  • See code samples for common use cases for integrating your tool chain to achieve centralized management and orchestration

Register for the webinar  

Stay up to date

We'll never share your email address and you can opt out at any time, we promise.

Loading form...
Your ad blocker may be blocking functionality on this page. Please disable for an improved experience.