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.

The following procedure shows how to create a Jenkins endpoint to use in your pipeline. To create a Jenkins endpoint, you must provide the URL of the Jenkins server and the admin password. Before using it in a pipeline, you validate the endpoint to verify that it can connect to the Jenkins server.

Prerequisites

Procedure

  1. Assign the project ID variable.
    project_id='<your_project_id>'
  2. Create a Jenkins endpoint.
    curl -X POST \
      $url/codestream/api/endpoints?apiVersion=$api_version \
      -H 'Content-Type: application/json' \
      -H "Authorization: Bearer $access_token"  \
      -d '{
    	"name": "<your_endpoint_name>",
    	"description": "",
    	"isRestricted": false,
    	"properties": {
    		"url": "<your_Jenkins_server_URL>",
    		"username": "admin",
    		"password": "<admin_passwd_for_Jenkins_server>",
    		"folderPath": "",
    		"pollInterval": 2,
    		"retryCount": 2,
    		"retryWaitSeconds": 3
    	},
    	"type": "jenkins",
    	"project": "'$project_id'"
    }' | jq "."
  3. Examine the response and assign the endpoint ID variable.
    endpoint_id='<your_endpoint_id>'
  4. To verify that the endpoint can connect to the Jenkins server, 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": "<your_endpoint_name>",
        "type": "jenkins",
        "properties": { 
            "url": "<your_Jenkins_server_URL>", 
            "username": "admin", 
            "password": "<admin_passwd_for_Jenkins_server>", 
            "folderPath": "", 
            "pollInterval": 2, 
            "retryCount": 2, 
            "retryWaitSeconds": 3 
        }
    } | jq "."
    Examine the response to verify that the endpoint is valid.

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.