Format a version string for use in packaging.
    
    >>> format_version([0,3,5])
    '0.3.5'
    >>> format_version([8, 8, 9], 23676)
    '8.8.9-jenkins-23676'
    >>> format_version([8, 8, 9], 23676, 'koekjes')
    '8.8.9-koekjes-23676'

def format_version(version, build_number=None, build_tag=BUILD_TAG):
    """
    Format a version string for use in packaging.
    
    >>> format_version([0,3,5])
    '0.3.5'
    >>> format_version([8, 8, 9], 23676)
    '8.8.9-jenkins-23676'
    >>> format_version([8, 8, 9], 23676, 'koekjes')
    '8.8.9-koekjes-23676'
    """
    formatted_version = ".".join(map(str, version))

    if build_number is not None:
        return "{formatted_version}-{build_tag}-{build_number}".format(**locals())
    
    return formatted_version