Use CircleCI version 2.1 at the top of your .circleci/config.yml file.
1
version: 2.1
Add the orbs
stanza below your version, invoking the orb:
1
2
orbs:
codestream: vmware/codestream@1.0.0
Use codestream
elements in your existing workflows and jobs.
Opt-in to use of uncertified orbs on your organization’s Security settings page.
Authenticates to the VMware Cloud Service Platform, obtains a bearer token, and calls a Code Stream pipeline via API using the pipeline ID
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
csp_token | Refresh token from VMware Cloud Services Platform | No | CSP_REFRESH_TOKEN | env_var_name |
pipeline_id | ID for a Code Stream pipeline | No | PIPELINE_ID | env_var_name |
Authenticate to Code Stream and Execute Pipeline
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
csp_token | - | No | CSP_REFRESH_TOKEN | env_var_name |
pipeline_id | - | No | PIPELINE_ID | env_var_name |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# This code is licensed from CircleCI to the user under the MIT license.
# See here for details: https://circleci.com/developer/orbs/licensing
commands:
authenticate:
description: Authenticate to Code Stream and Execute Pipeline
parameters:
csp_token:
default: CSP_REFRESH_TOKEN
type: env_var_name
pipeline_id:
default: PIPELINE_ID
type: env_var_name
steps:
- run:
command: |
echo "export json='Content-Type:application/json'" >> $BASH_ENV
echo "export auth='{"refreshToken":"$<<parameters.csp_token>>"}'" >> $BASH_ENV
echo "export data='{"comments": "execute", "input": {}}'" >> $BASH_ENV
echo "export url='https://api.mgmt.cloud.vmware.com/pipeline/api/pipelines/"$<<parameters.pipeline_id>>"/executions'" >> $BASH_ENV
name: Configure Variables
- run:
command: |
source $BASH_ENV
echo "export header='Authorization: Bearer $(curl -X POST https://api.mgmt.cloud.vmware.com/iaas/login -H $json -d $auth | jq -r .token)'" >> $BASH_ENV
name: Export Authentication Header
- run:
command: |
source $BASH_ENV
curl -X POST $url -H $json -H "$header" -d "$data"
name: Execute API Call
description: An Orb for Calling Code Stream Pipelines
executors:
python:
docker:
- image: circleci/python:latest
jobs:
callcs:
description: |
Authenticates to the VMware Cloud Service Platform, obtains a bearer token, and calls a Code Stream pipeline via API using the pipeline ID
executor: python
parameters:
csp_token:
default: CSP_REFRESH_TOKEN
description: Refresh token from VMware Cloud Services Platform
type: env_var_name
pipeline_id:
default: PIPELINE_ID
description: ID for a Code Stream pipeline
type: env_var_name
steps:
- authenticate:
csp_token: << parameters.csp_token >>
pipeline_id: <<parameters.pipeline_id>>
version: 2.1