Send data to a BigQuery data table when a new cloud build event is emitted from Pub/Sub.
### How this function works
Cloud Build sends all build event updates, along with build metadata, to Pub/Sub on the cloud-builds topic. BigQuery cloudBuildNotifier function can be configured to listen to that topic and send messages to the BigQuery data table.
### Prerequisites
* You must have previous knowledge of **BigQuery**.
* You must have the **BigQuery** API available.
* You must grant BigQuery read/write access to the default service account that will be used. For more information about this, see https://cloud.google.com/iam/docs/service-accounts#default
### Function details
This function listens when a new build event update is emitted from Pub/Sub on the cloud-builds topic and then adds this record to a BigQuery table.
To install this function, you need to specify the name of the dataset and the name of the table into which the events will be inserted as follows:
* **DATASET_NAME**: The name of the dataset to store the build events. If it does not exist, the function will create it.
* **TABLE_NAME**: The name of the table to store the build events. If it does not exist, the function will create it.
>It is recommended that you do not create the table manually, but let the function create it for you.
The table created will have the following schema:
```JSON
{
"fields": [
{
"name": "projectId",
"type": "STRING"
},
{
"name": "id",
"type": "STRING",
"mode": "REQUIRED"
},
{
"name": "buildTriggerId",
"type": "STRING"
},
{
"name": "status",
"type": "STRING"
},
{
"name": "images",
"type": "STRING",
"mode": "REPEATED"
},
{
"name": "steps",
"type": "RECORD",
"mode": "REPEATED",
"fields": [
{
"name": "name",
"type": "STRING"
},
{
"name": "id",
"type": "STRING"
},
{
"name": "status",
"type": "STRING"
},
{
"name": "args",
"type": "STRING",
"mode": "REPEATED"
},
{
"name": "timing",
"type": "RECORD",
"fields": [
{
"name": "startTime",
"type": "TIMESTAMP"
},
{
"name": "endTime",
"type": "TIMESTAMP"
}
]
},
{
"name": "pullTiming",
"type": "RECORD",
"fields": [
{
"name": "startTime",
"type": "TIMESTAMP"
},
{
"name": "endTime",
"type": "TIMESTAMP"
}
]
}
]
},
{
"name": "createTime",
"type": "TIMESTAMP"
},
{
"name": "startTime",
"type": "TIMESTAMP"
},
{
"name": "finishTime",
"type": "TIMESTAMP"
},
{
"name": "tags",
"type": "STRING",
"mode": "REPEATED"
},
{
"name": "options",
"type": "RECORD",
"fields": [
{
"name": "env",
"type": "STRING",
"mode": "REPEATED"
}
]
},
{
"name": "logUrl",
"type": "STRING"
},
{
"name": "substitutions",
"type": "RECORD",
"mode": "REPEATED",
"fields": [
{
"name": "key",
"type": "STRING"
},
{
"name": "value",
"type": "STRING"
}
]
}
]
}
```
### Resources
* [BigQuery docs](https://cloud.google.com/bigquery/docs)