To create an endpoint, you make a POST request with the endpoint properties. Then you use the ID of the endpoint created to validate it.
Prerequisites
- Verify that all general prerequisites and prerequisites for the Code Stream service have been satisfied. See Prerequisites for API Use Case Examples.
- Verify that you have the ID for the project that you want to use for your endpoint. See Create a Project with the Project Service API.
Procedure
Example: Create a Jenkins endpoint
Create a Jenkins endpoint named jenkins-example.
Assign variables.
$ url='https://appliance.domain.com'
$ api_version='2019-10-17'
$ project_id='MyProject1'
Create the Jenkins endpoint.
$ curl -X POST \ $url/codestream/api/endpoints?apiVersion=$api_version \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $access_token" \ -d '{ "name": "jenkins-example", "description": "", "isRestricted": false, "properties": { "url": "http://example-jenkins-server.mycompany.com:8080", "username": "admin", "password": "1146Examplea3eJenkin5d004Pa55word", "folderPath": "", "pollInterval": 2, "retryCount": 2, "retryWaitSeconds": 3 }, "type": "jenkins", "project": "'$project_id'" }' | jq "."
The response from your request shows the endpoint ID.
{ "project": "MyProject1", "kind": "ENDPOINT", "id": "85723b0b-a819-435e-8d71-f8f834cdbaa2", "name": "jenkins-example", "description": "", "updatedBy": "[email protected]", "createdAt": "2022-08-03T08:57:10.033+0000", "updatedAt": "2022-11-04T11:14:49.315+0000", "_link": "/codestream/api/endpoints/85723b0b-a819-435e-8d71-f8f834cdbaa2", ... }
Assign the endpoint ID variable.
$ endpoint_id='85723b0b-a819-435e-8d71-f8f834cdbaa2'
Validate the endpoint.
$ curl -X POST \ $url/codestream/api/endpoint-validation?apiVersion=$api_version \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $access_token" \ -d '{ "project": "'$project_id'", "kind": "ENDPOINT", "id": "'$endpoint_id'", "name": "jenkins-example", "type": "jenkins", "properties": { "url": "http://example-jenkins-server.mycompany.com:8080", "username": "admin", "password": "1146Examplea3eJenkin5d004Pa55word", "folderPath": "", "pollInterval": 2, "retryCount": 2, "retryWaitSeconds": 3 } } | jq "."
The status message in the response verifies that the endpoint is valid.
{ "output": {}, "status": "COMPLETED", "statusMessage": "Valid Jenkins Endpoint", "duration": 0 }
What to do next
Create a pipeline with a Jenkins task that uses the endpoint.