Get a list of builds within your project
cr_build_list_filter outputs valid filters for cr_build_list
's filter argument
cr_build_list(
filter = NULL,
projectId = cr_project_get(),
pageSize = 1000,
data_frame_output = TRUE
)
cr_build_list_filter(
field,
operator = c("=", "!=", ">", ">=", "<", "<="),
value
)
Text filter for the list - use cr_build_list_filter()
or a raw string
ID of the project
How many builds to fetch per page
If TRUE will output a data.frame of a subset of info from the builds, merged with the list of triggers from cr_buildtrigger_list. Set to FALSE to return a list of Build objects similar to output from cr_build_status
The field you want to filter on. Will validate.
The type of comparision for the filter
The value for the filter's field. Auto-formats POSIXct
and Date
objects
When data_frame_output=TRUE
results are sorted with the latest buildStartTime in the first row
If filter is NULL
then this will return all historic builds. To use filters, ensure you use ""
and not ''
to quote the fields e.g. 'status!="SUCCESS"'
and 'status="SUCCESS"'
- see Filtering build results docs. cr_build_list_filter
helps you construct valid filters. More complex filters can be done using a combination of paste and cr_build_list_filter()
- see examples
Use POSIXct via functions like Sys.time to have them formatted into valid timestamps for time related fields, or Date objects via functions like Sys.Date
https://cloud.google.com/build/docs/api/reference/rest/v1/projects.builds/list
Other Cloud Build functions:
Build()
,
RepoSource()
,
Source()
,
StorageSource()
,
cr_build_artifacts()
,
cr_build_logs()
,
cr_build_make()
,
cr_build_status()
,
cr_build_targets()
,
cr_build_upload_gcs()
,
cr_build_wait()
,
cr_build_write()
,
cr_build_yaml_artifact()
,
cr_build_yaml_secrets()
,
cr_build_yaml()
,
cr_build()
if (FALSE) {
# merge with buildtrigger list
cr_build_list()
# output a list of build objects
cr_build_list(data_frame_output = FALSE)
# output a list of builds that failed using raw string
cr_build_list('status!="SUCCESS"')
# output builds for a specific trigger using raw string
cr_build_list('trigger_id="af2c7ddc-e4eb-4170-b938-a4babb53bac6"')
# use cr_build_list_filter to help validate filters
failed_builds <- cr_build_list_filter("status", "!=", "SUCCESS")
cr_build_list(failed_builds)
f1 <- cr_build_list_filter(
"trigger_id", "=", "af2c7ddc-e4eb-4170-b938-a4babb53bac6"
)
cr_build_list(f1)
# do AND (and other) filters via paste() and cr_build_list_filter()
cr_build_list(paste(f1, "AND", failed_builds))
# builds in last 5 days
last_five <- cr_build_list_filter("create_time", ">", Sys.Date() - 5)
cr_build_list(last_five)
# builds in last 60 mins
last_hour <- cr_build_list_filter("create_time", ">", Sys.time() - 3600)
cr_build_list(last_hour)
# builds for this package's buildtrigger
gcr_trigger_id <- "0a3cade0-425f-4adc-b86b-14cde51af674"
gcr_bt <- cr_build_list_filter(
"trigger_id",
value = gcr_trigger_id
)
gcr_builds <- cr_build_list(gcr_bt)
# get logs for last build
last_build <- gcr_builds[1, ]
last_build_logs <- cr_build_logs(log_url = last_build$bucketLogUrl)
tail(last_build_logs, 10)
}