import re


def get_build_id(log_file):
    """This function finds the build ID within the appropriate log file.

    Inputs:
        - log_file: Absolute path to the Klocwork log file kwloaddb.log [string]

    Outputs:
        - build_id: The build ID that is used by Klocwork to identify the analysis [string]
    """

    # Initialize variables
    build_id = None

    # Read in the first line of the log file
    with open(log_file, 'r') as input_fh:
        log_line = input_fh.readline()

    # Split the line
    line_split = filter(None, re.split('[" ]', log_line))

    # Find the build ID parameter
    for item in line_split:
        if item.startswith('build'):
            build_id = item
            break

    return build_id