I am wondering if list pipelines can be extended to support filtering
Hey @dvnrsn!
Welcome to the community!
It’s not possible to add filtering to the REST API at the moment, but you can do it with GraphQL. For example filtering by name, you can have something like:
query {
organization(slug:"{org-slug}") {
pipelines(first:100, search:"something") {
edges {
node {
name
}
}
}
}
}
Best!
Thank you this is interesting.
I would need to filter on repository (i.e., get pipelines that include a certain repo name).
Also I see there is a max of 500 and given the requirement of “first” or “last” is there a way to paginate. We’re looking at a few thousand.
Hey!
You can filter by repository, you have available the PipelineRepositoryInput object, and you can also do pagination with the PageInfo object.
Best!
Forgive my ignorance of GraphQL and thank you for your help! I am able to get the PageInfo object on pipelines but I am still a little unsure how to filter by repo. I’ve tried
repository(url:"git@github.com:dvnrsn/my-repo.git") {
pipelines(repository:"git@github.com:dvnrsn/my-repo.git") {
Essentially I want to get only the pipelines that have repos that match some URL ^.
Perhaps the answer would be something like this:
pipelines(filter: {url: {eq: "git@github"}}) {
edges {
node {
name
repository {
url
}
}
}
}
It also seems not to support a where
which could be useful:
pipelines(where: {node: {repository: {eq:""}}}) {
Hey!
That is correct, the query will be something like:
query {
organization(slug:"{org}") {
pipelines(first:100, repository: { url: "{url}"}) {
edges {
node {
name
}
}
}
}
}
We don’t support where clause.
Best,
Resolved with
query GetPipelines(
$repo0: PipelineRepositoryInput!
$repo1: PipelineRepositoryInput!
) {
organization(slug: "org-slug") {
repos_0: pipelines(first: 500, repository: $repo0) {
...PipelineConnectionFields
}
repos_1: pipelines(first: 500, repository: $repo1) {
...PipelineConnectionFields
}
}
}
Fragment PipelineConnectionFields can also include
pageInfo {
endCursor
hasNextPage
}