Uploading custom data to the API

Upload metrics data by using an external client to access API endpoints.

Uploading data to the API

HCL Accelerate provides numerous plug-ins that you can use to integrate data into your releases and values streams. If a plug-in is not available for your environment, or if you prefer to manage your own data integration, you can use an external client to upload data to REST API endpoints or GraphQL™. A tutorial that describes how to upload custom metrics is available.

The following examples use the Curl command line tool for typical POST use cases. You authorize requests with user access keys that you create in HCL Accelerate.

Note: Until new users are assigned to teams, they are automatically assigned to the Default team in the Viewer and Participant roles. Users in these roles can view objects, such as releases and value streams, but they cannot create or edit them. Additionally, users in these roles can generate user access tokens and access API endpoints with GET requests. Administrators grant users elevated permissions when they assign them to roles such as Lead Developer or Release Manager.

You can find GraphQL at https://my_accelerate:port/release-events-api/graphiql.

Normalized metrics example

The following example provides a Curl POST request that sends metrics data to the https://my_accelerate:port/api/v1/metrics endpoint.

You can define custom metric definitions and upload metric data using an external client, such as curl.

curl -k -request POST \
-url https://my_accelerate:port/api/v1/metrics \
-H "content-type: application/json" \
-H "Authorization: UserAccessKey my_access_key" \
--data '{
"tenantId": "my_tenant_ID",
"dataSet": "Homegrown",
"record": {
"metricDefinitionId": "Unit Tests",
"recordName": "UT on ABC",
"pluginType": "plugin",
"executionDate": "2019-05-01T21:09:00.000Z",
"dataFormat": "custom",
"value":
{ "passed": 38, "failed": 1 }

},
"application":
{ "name": "my-app" }

}'

Metrics file upload example

The following example provides a Curl POST request that uploads a file at the https://my_accelerate:port/api/v1/upload endpoint:

curl --request POST \
--url https://my_accelerate:port/api/v1/metrics/upload \
-H "Authorization: UserAccessKey my_access_key" \
-F file=@junit.xml \
-F 'payload={
"tenantId": "my_tenant_ID",
"dataSet": "Feb",
"application":
{ "name": "my App22" }

,
"environment": "Prod",
"record":
{ "metricDefinitionId": "Functional Tests", "pluginType": "junitXML", "dataFormat": "junitXML" }

}
' \
-k

Deployment data example

The following example provides a Curl POST request that sends Jenkins deployment data to the https://my_accelerate:port/api/v1/deployments endpoint:

curl --request POST \
-H "Authorization: UserAccessKey my_access_key" \
-H 'content-type: application/json' \
-k --url https://my_accelerate:port/api/v1/deployments \
--data '{
"id_external": 8888,
"tenant_id": "my_tenant_ID",
"version_name": "1.2.3",
"version_id_external": "V1.2.3",
"result": "Succeeded",
"description" : "Application API Release Failed",
"by_user": "username",
"application":
{ "name": "cool-Jenkins-App" }

,
"start_time": "2019-02-02 00:10:58.856+00:00",
"end_time": "2019-02-02 00:12:58.856+00:00",
"type": "Jenkins",
"environment_id": "my_environmant_ID",
"environment_name": "QA"
}'

Build data example

The following example provides a Curl POST request that sends build data to the https://my_accelerate:port/api/v1/builds endpoint:

curl -k --request POST \
--url https://my_accelerate/api/v1/builds \
-H "content-type: application/json" \
-H "Authorization: UserAccessKey my_access_key" \
--data '{
"id": "131",
"source": "Jenkins",
"tenantId": "my_tenant_ID",
"name": "IBM Build",
"status": "failure",
"application":
{ "name": "Accelerate SE" }

,
"url": "https:/12.34.20.45/job/VSE/master/5",
"number": 5,
"labels": ["Everything"],
"startTime": "2019-03-14 20:10:58.856+00:00",
"endTime": "2019-03-14 20:10:58.856+00:00",
"requestor": "admin"
}'