Description
You are able to access Rest API through a PowerShell script. To access the Rest API for CloudBees CD (CloudBees Flow) requires the domain name for the URI and a User.
All Scripts require the command Invoke-RestMethod, with the parameters: URI, headers, content type and method.
It should be in the following format.
Invoke-RestMethod -uri -Headers -ContentType "application/json" -Method
The uri will generally be in this format:
https://yourCDServer/rest/v1.0/?
The Header will be generated earlier in the Powershell script. It will contain the encoded Username and Password.
Method will follow REST standards of "Get, Post, Put, or Delete"
The content type should be set to "application/json"
Query varies by which parameters you use. To find details on all the parameters used for a specific function or method, please visit: https://yourCDServer/rest/doc/v1.0/
For more details on the methods used, please see 'Using Powershell to call REST API of CloudBees CD (CloudBees Flow)'.
Below are a series of examples on the format of some the API functions
Function |
Method |
Path and Query |
Add a New Property to a Property Sheet |
Post |
/rest/v1.0/properties/?request=incrementProperty\& |
Set a Property in a Property sheet |
Put |
rest/v1.0/properties/tester?\&value= |
Get a Property |
Get |
/rest/v1.0/properties/? |
Login |
Post |
/rest/v1.0/sessions?username=\&password= |
Get Job Details |
Get |
/rest/v1.0/jobs/{jobId}?request=getJobStatus |
Publish Artifact Version |
Post |
/rest/v1.0/artifacts/{artifactName}/artifactVersions? |
Get Artifact Version |
Get |
/rest/v1.0/artifactVersions/{Artifact Name} |
Create Job step |
Post |
/rest/v1.0/jobSteps? |
Get Server Status |
Get |
/rest/v1.0/server/status? |
Export |
Get |
/rest/v1.0/server? |
Import |
Post |
/rest/v1.0/objects? |
Many of these functions contain optional Flags and Queries. Please see the Rest API details to see these optional flags.