Retrieve the CJP and Jenkins URI of an Item

Article ID:115002583232
1 minute readKnowledge base

Issue

  • I want to get the CJP URI (cjp:///) of a particular item in my CJP cluster

  • I want to get the Jenkins URI (jenkins://) of a particular item in my CJP cluster

Environment

Resolution

There are currently 2 supported URI scheme in a CJP cluster:

  • The jenkins scheme: jenkins://instanceId/path/to/folder

  • The cjp scheme: cjp:///path/from/root/of/cjoc

There are used by cluster-wide operations to locate an item in a CJP cluster. These operations includes:

The URI can be constructed by building the names of each item which could be cumbersome and error-prone.

But there is a simpler way to retrieve the URI of an item inside a CJP cluster: the /platform-uri/ action.

Use the /platform-uri action

An action is provided by the and returns the URI of an item for the scheme specified:

  • You can append /platform-uri?scheme=cjp to an item URL to get the CJP URI of that item

  • You can append /platform-uri?scheme=jenkins to an item URL to get the Jenkins URI of that item

Example of a path of a specific controller:

$ curl -u "USER:API_TOKEN" -X GET "https://my.dev.controller.com/platform-uri/?scheme=cjp"
cjp:///my-dev-master
$ curl -u "USER:API_TOKEN" -X GET "https://my.dev.controller.com/platform-uri/?scheme=jenkins"
jenkins://<instanceIdOfMyDevcontroller>/

Example of a path of a specific Folder:

$ curl -u "USER:API_TOKEN" -X GET "https://my.dev.controller.com/job/projectA/platform-uri/?scheme=cjp"
cjp:///my-dev-master/projectA
$ curl -u "USER:API_TOKEN" -X GET "https://my.dev.controller.com/job/projectA/platform-uri/?scheme=jenkins"
jenkins://<instanceIdOfMyDevcontroller>/projectA

Example of a path of a specific Job:

$ curl -u "USER:API_TOKEN" -X GET "https://my.dev.controller.com/job/projectA/job/jobA/platform-uri/?scheme=cjp"
cjp:///my-dev-master/projectA/jobA
$ curl -u "USER:API_TOKEN" -X GET "https://my.dev.controller.com/job/projectA/job/jobA/platform-uri/?scheme=jenkins"
jenkins://<instanceIdOfMyDevcontroller>/projectA/jobA