# 3.8.5. Build data connector

class buildbot.db.build_data.BuildDataConnectorComponent

  This class handles build data. Build data is potentially large transient text data attached to the build that the steps can use for their operations. One of the use cases is to carry large amount of data from one step to another where storing that data on the worker is not feasible. This effectively forms a key-value store for each build. It is valid only until the build finishes and all reporters are done reporting the build result. After that the data may be removed from the database.

  An instance of this class is available at `master.db.build_data`.

  Builds are indexed by build_dataid and their contents represented as `BuildDataModel` dataclass, with the following fields:

  - `id` (the build data ID, globally unique)

  - `buildid` (the ID of the build that the data is attached to)

  - `name` (the name of the data)

  - `value` (the value of the data. It must be an instance of `bytes`. Can be `None` when queried with `getBuildDataNoValue`)

  - `source` (an string identifying the source of this value)

  setBuildData(buildid, name, value, source)
    Parameters:

      - buildid (integer) – build id to attach data to

      - name (unicode) – the name of the data

      - value (bytestr) – the value of the data as `bytes`.

    Parma unicode source:

      the source of the data

    Returns:

      Deferred

    Adds or replaces build data attached to the build.

  getBuildData(buildid, name)
    Parameters:

      - buildid (integer) – build id retrieve data for

      - name (unicode) – the name of the data

    Returns:

      `BuildDataModel` or `None`, via Deferred

    Get a single build data, in the format described above, specified by build and by name. Returns `None` if build has no data with such name.

  getBuildDataNoValue(buildid, name)
    Parameters:

      - buildid (integer) – build id retrieve data for

      - name (unicode) – the name of the data

    Returns:

      `BuildDataModel` or `None`, via Deferred

    Get a single build data, in the format described above, specified by build and by name. The `value` field is omitted. Returns `None` if build has no data with such name.

  getAllBuildDataNoValues(buildid, name=None)
    Parameters:

      - buildid (integer) – build id retrieve data for

      - name (unicode) – the name of the data

    Returns:

      a list of `BuildDataModel`

    Returns all data for a specific build. The values are not loaded. The returned values can be filtered by name

  deleteOldBuildData(older_than_timestamp)
    Parameters:

      older_than_timestamp (integer) – the build data whose build’s `complete_at` is older than `older_than_timestamp` will be deleted.

    Returns:

      Deferred

    Delete old build data (helper for the `build_data_horizon` policy). Old logs have their build data deleted from the database as they are only useful while build is running and shortly afterwards.