Class BuildkiteClient
java.lang.Object
org.sourcelab.buildkite.api.client.BuildkiteClient
API Client for Buildkite's REST Api.
See API Documentation:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncancelBuild(String organizationSlugId, String pipelineSlugId, long buildNumber) Cancels the build if its state is either scheduled or running.createBuild(CreateBuildOptions createBuildOptions) Creates a new build to be executed.createBuild(CreateBuildOptionsBuilder createBuildOptions) Creates a new build to be executed.booleanDeletes/Revokes the current AccessToken.<T> TexecuteRequest(Request<T> request) Execute the given request, returning the parsed response, or throwing the appropriate exception if an error was returned from the API.<T> TfirstPage(PageableResponse<T> response) Retrieve the first page of results from the previously retrieved request.Retrieve details about the current AccessToken.Retrieve a specific build based on the filter criteria.getBuild(GetBuildFilters filters) Retrieve a specific build based on the filter criteria.getBuild(GetBuildFiltersBuilder filters) Retrieve a specific build based on the filter criteria.getMeta()Retrieves metadata endpoint.getOrganization(String organizationSlugId) Retrieve specific organization via its Organization slug id.getPipeline(String organizationSlugId, String pipelineSlugId) Retrieve specific pipeline via its Organization and Pipeline Slug Ids.getUser()Retrieves the current user associated with the current access token.<T> TlastPage(PageableResponse<T> response) Retrieve the last page of results from the previously retrieved request.Retrieve all Builds accessible to the current user/API access token, across all Organizations.listBuilds(BuildFilters filters) Retrieve all builds which match the supplied search criteria.listBuilds(BuildFiltersBuilder filtersBuilder) Retrieve all builds which match the supplied search criteria.listEmojis(String orgIdSlug) List all Emojis defined in the given Organization.Retrieve all Organizations accessible to the current user/API access token.listOrganizations(OrganizationFilters filters) Retrieve all Organizations accessible to the current user/API access token.Retrieve all Organizations accessible to the current user/API access token.listPipelines(String organizationSlugId) Retrieve all Pipelines accessible to the current user/API access token for the given Organization.listPipelines(PipelineFilters filters) Retrieve all Pipelines accessible to the current user/API access token for the given Organization.listPipelines(PipelineFiltersBuilder filters) Retrieve all Pipeline accessible to the current user/API access token for the given Organization.<T> TnextPage(PageableResponse<T> response) Retrieve the next page of results from the previously retrieved request.ping()Make a 'test' or 'hello world' request to the Buildkite API.<T> TpreviousPage(PageableResponse<T> response) Retrieve the previous page of results from the previously retrieved request.rebuildBuild(String organizationSlugId, String pipelineSlugId, long buildNumber) Retries a build.retryJob(RetryJobOptions options) Retries a failed or timed_out job.retryJob(RetryJobOptionsBuilder options) Retries a failed or timed_out job.unblockJob(UnblockJobOptions options) Unblocks a build's "Block pipeline" job.unblockJob(UnblockJobOptionsBuilder options) Unblocks a build's "Block pipeline" job.
-
Constructor Details
-
BuildkiteClient
Constructor.- Parameters:
configuration- The configuration for the client.
-
-
Method Details
-
ping
Make a 'test' or 'hello world' request to the Buildkite API. Can be used to validate connectivity to the API.- Returns:
- Response details from the ping request.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
getAccessToken
Retrieve details about the current AccessToken.- Returns:
- Details about the current AccessToken.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
deleteAccessToken
Deletes/Revokes the current AccessToken.- Returns:
- Details about the current AccessToken.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
getUser
Retrieves the current user associated with the current access token.- Returns:
- Details about the current User.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
listOrganizations
Retrieve all Organizations accessible to the current user/API access token. Results will be paged.- Returns:
- All Organizations accessible to the current user/API access token. Results will be paged if the number of results exceeds 30.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
listOrganizations
public ListOrganizationsResponse listOrganizations(OrganizationFiltersBuilder filters) throws BuildkiteException Retrieve all Organizations accessible to the current user/API access token. Results will be paged.- Parameters:
filters- Filter criteria.- Returns:
- All Organizations accessible to the current user/API access token. Results will be paged if the number of results exceeds 30.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
listOrganizations
public ListOrganizationsResponse listOrganizations(OrganizationFilters filters) throws BuildkiteException Retrieve all Organizations accessible to the current user/API access token. Results will be paged.- Parameters:
filters- Filter criteria.- Returns:
- All Organizations accessible to the current user/API access token. Results will be paged if the number of results exceeds 30.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
getOrganization
Retrieve specific organization via its Organization slug id.- Parameters:
organizationSlugId- Slug of the organization to retrieve.- Returns:
- Organization matching the slug, if found.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
listPipelines
public ListPipelinesResponse listPipelines(PipelineFiltersBuilder filters) throws BuildkiteException Retrieve all Pipeline accessible to the current user/API access token for the given Organization. Results will be paged.- Parameters:
filters- Filter criteria.- Returns:
- All Pipelines accessible to the current user/API access token. Results will be paged if the number of results exceeds 30.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
listPipelines
Retrieve all Pipelines accessible to the current user/API access token for the given Organization. Results will be paged.- Parameters:
filters- Filter criteria.- Returns:
- All Pipelines accessible to the current user/API access token. Results will be paged if the number of results exceeds 30.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
listPipelines
Retrieve all Pipelines accessible to the current user/API access token for the given Organization. Results will be paged.- Parameters:
organizationSlugId- Organization Slug Id to retrieve pipelines for.- Returns:
- All Pipelines accessible to the current user/API access token for the given Organization. Results will be paged if the number of results exceeds 30.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
getPipeline
public Optional<Pipeline> getPipeline(String organizationSlugId, String pipelineSlugId) throws BuildkiteException Retrieve specific pipeline via its Organization and Pipeline Slug Ids.- Parameters:
organizationSlugId- Slug of the organization to retrieve.pipelineSlugId- Slug of the pipeline to retrieve.- Returns:
- Pipeline matching the slug, if found.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
listBuilds
Retrieve all Builds accessible to the current user/API access token, across all Organizations. Results will be paged.- Returns:
- All Builds accessible to the current user/API access token, across all Organizations. Results will be paged if the number of results exceeds 30.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
listBuilds
Retrieve all builds which match the supplied search criteria.- Parameters:
filtersBuilder- Filter criteria.- Returns:
- All builds which match the supplied search criteria. Results will be paged if the number of results exceeds 30 (or the page limit specified in the search criteria).
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
listBuilds
Retrieve all builds which match the supplied search criteria.- Parameters:
filters- Filter criteria.- Returns:
- All builds which match the supplied search criteria. Results will be paged if the number of results exceeds 30 (or the page limit specified in the search criteria).
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
getBuild
Retrieve a specific build based on the filter criteria.- Parameters:
filters- Filter criteria.- Returns:
- The build which matches the criteria if found.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
getBuild
Retrieve a specific build based on the filter criteria.- Parameters:
organizationSlugId- Organization associated with the build.pipelineSlugId- Pipeline associated with the build.buildNumber- The build number.- Returns:
- The build which matches the criteria if found.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
getBuild
Retrieve a specific build based on the filter criteria.- Parameters:
filters- Filter criteria.- Returns:
- The build which matches the criteria if found.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
cancelBuild
Cancels the build if its state is either scheduled or running.- Parameters:
organizationSlugId- Organization associated with the build.pipelineSlugId- Pipeline associated with the build.buildNumber- The build number.- Returns:
- Updated Build instance.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
createBuild
Creates a new build to be executed.- Parameters:
createBuildOptions- Defines the build to be created.- Returns:
- Created Build instance.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
createBuild
Creates a new build to be executed.- Parameters:
createBuildOptions- Defines the build to be created.- Returns:
- Created Build instance.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
rebuildBuild
Retries a build.- Parameters:
organizationSlugId- Organization associated with the build.pipelineSlugId- Pipeline associated with the build.buildNumber- The build number.- Returns:
- Updated Build instance.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
retryJob
Retries a failed or timed_out job. You can only retry each job.id once. To retry a "second time" use the new job.id returned in the first retry query.- Parameters:
options- Defines which Job to retry.- Returns:
- Updated job instance.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
retryJob
Retries a failed or timed_out job. You can only retry each job.id once. To retry a "second time" use the new job.id returned in the first retry query.- Parameters:
options- Defines which Job to retry.- Returns:
- Updated job instance.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
unblockJob
Unblocks a build's "Block pipeline" job. The job's unblockable property indicates whether it is able to be unblocked, and the unblock_url property points to this endpoint.- Parameters:
options- Defines which Job to unblock.- Returns:
- Updated job instance.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
unblockJob
Unblocks a build's "Block pipeline" job. The job's unblockable property indicates whether it is able to be unblocked, and the unblock_url property points to this endpoint.- Parameters:
options- Defines which Job to unblock.- Returns:
- Updated job instance.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
listEmojis
List all Emojis defined in the given Organization.- Parameters:
orgIdSlug- Organization Id slug to retrieve list of emojis for.- Returns:
- List of Emojis.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
getMeta
Retrieves metadata endpoint.- Returns:
- Details about the current User.
- Throws:
BuildkiteException- if API returns an error response.- See Also:
-
nextPage
Retrieve the next page of results from the previously retrieved request.- Type Parameters:
T- The parsed return object representing the result.- Parameters:
response- Previously retrieved result/response to retrieve the next page of results for.- Returns:
- The next page of results.
- Throws:
InvalidPagingRequestException- if no next page exists to retrieve.BuildkiteException- if API returns an error response.
-
previousPage
Retrieve the previous page of results from the previously retrieved request.- Type Parameters:
T- The parsed return object representing the result.- Parameters:
response- Previously retrieved result/response to retrieve the previous page of results for.- Returns:
- The previous page of results.
- Throws:
InvalidPagingRequestException- if no previous page exists to retrieve.BuildkiteException- if API returns an error response.
-
firstPage
Retrieve the first page of results from the previously retrieved request.- Type Parameters:
T- The parsed return object representing the result.- Parameters:
response- Previously retrieved result/response to retrieve the first page of results for.- Returns:
- The first page of results.
- Throws:
InvalidPagingRequestException- if no previous page exists to retrieve.BuildkiteException- if API returns an error response.
-
lastPage
Retrieve the last page of results from the previously retrieved request.- Type Parameters:
T- The parsed return object representing the result.- Parameters:
response- Previously retrieved result/response to retrieve the last page of results for.- Returns:
- The last page of results.
- Throws:
InvalidPagingRequestException- if no previous page exists to retrieve.BuildkiteException- if API returns an error response.
-
executeRequest
Execute the given request, returning the parsed response, or throwing the appropriate exception if an error was returned from the API. This method scoped public to allow for user defined requests to be executed by the library as an extension point.- Type Parameters:
T- The parsed response object.- Parameters:
request- The request to execute.- Returns:
- The parsed response object.
- Throws:
BuildkiteException- if API returns an error response.
-