Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JobList API to support Tree and Depth #309

Open
choweiyuan opened this issue Aug 18, 2023 · 0 comments
Open

JobList API to support Tree and Depth #309

choweiyuan opened this issue Aug 18, 2023 · 0 comments

Comments

@choweiyuan
Copy link
Contributor

Expected Behavior

JobList API current supports listing all jobs within the folder. We could support more fine-grained listing by using tree/depth

Current Behavior

JobList API current supports listing all jobs within the folder without ability to filter by tree/depth.

Context

We have >= 1k jobs within a folder (within a folder and within another folder..). I need to recursively call this API which isn't great. Fortunately Jenkins API supports using tree/depth.

As per http://jenkinsurl/api page:

Controlling the amount of data you fetch
The tree query parameter allows you to explicitly specify and retrieve only the information you are looking for, by using an XPath-ish path expression. The value should be a list of property names to include, with sub-properties inside square braces. Try tree=jobs[name],views[name,jobs[name]] to see just a list of jobs (only giving the name) and views (giving the name and jobs they contain). Note: for array-type properties (such as jobs in this example), the name must be given in the original plural, not in the singular as the element would appear in XML (). This will be more natural for e.g. json?tree=jobs[name] anyway: the JSON writer does not do plural-to-singular mangling because arrays are represented explicitly.

For array-type properties, a range specifier is supported. For example, tree=jobs[name]{0,10} would retrieve the name of the first 10 jobs. The range specifier has the following variants:

{M,N}: From the M-th element (inclusive) to the N-th element (exclusive).
{M,}: From the M-th element (inclusive) to the end.
{,N}: From the first element (inclusive) to the N-th element (exclusive). The same as {0,N}.
{N}: Just retrieve the N-th element. The same as {N,N+1}.
Another way to retrieve more data is to use the depth=N query parameter. This retrieves all the data up to the specified depth. Compare depth=0 and depth=1 and see what the difference is for yourself. Also note that data created by a smaller depth value is always a subset of the data created by a bigger depth value.

Because of the size of the data, the depth parameter should really be only used to explore what data Jenkins can return. Once you identify the data you want to retrieve, you can then come up with the tree parameter to exactly specify the data you need.

Steps to Reproduce (for bugs)

Your Environment

ARG jenkins_tag=2.401.3-lts-jdk17

** I'm happy to contribute this

choweiyuan added a commit to choweiyuan/jenkins-rest that referenced this issue Aug 22, 2023
choweiyuan added a commit to choweiyuan/jenkins-rest that referenced this issue Aug 23, 2023
choweiyuan added a commit to choweiyuan/jenkins-rest that referenced this issue Aug 23, 2023
choweiyuan added a commit to choweiyuan/jenkins-rest that referenced this issue Aug 23, 2023
choweiyuan added a commit to choweiyuan/jenkins-rest that referenced this issue Aug 23, 2023
choweiyuan added a commit to choweiyuan/jenkins-rest that referenced this issue Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant