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
)

Arguments

filter

Text filter for the list - use cr_build_list_filter() or a raw string

projectId

ID of the project

pageSize

How many builds to fetch per page

data_frame_output

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

field

The field you want to filter on. Will validate.

operator

The type of comparision for the filter

value

The value for the filter's field. Auto-formats POSIXct and Date objects

Details

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

Examples

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)
}