Issue
It is difficult to determine which properties are available for REST API requests when the /api/schema endpoint is not user-friendly.
Resolution
Use the /api/schema endpoint to discover available properties for Jenkins resources.
-
Navigate to the resource URL and append
/apito view available API information.For example, for a build:
$JENKINS_URL/job/$JOB_NAME/$BUILD_NUMBER/api
-
Access the schema link shown on the API page:
$JENKINS_URL/job/$JOB_NAME/$BUILD_NUMBER/api/schema
-
Understand how the XML schema maps to JSON properties:
-
A
complexType name=$SOMETHINGcontains elements inside. -
If an element is not a simple type (such as
artifactswith typehudson.model.Run-Artifact), it has nested elements defined separately. -
The nested elements are defined as
complexType name=hudson.model.Run-Artifactwith their own elements.For example, to find the
artifactsproperty structure:-
Locate the main
complexTypefor the resource. -
Find the
artifactselement with typehudson.model.Run-Artifact. -
Search for
complexType name=hudson.model.Run-Artifactto see its nested properties.
-
-
-
Apply this schema knowledge to construct efficient
?tree=parameters following the best practices outlined in Best Practice For Using Jenkins REST API.