示例#1
0
def generate_references_remote(branch_name, git_path, tests_directory):
    username = input('Enter username for teamcity.nvidia.com: ')
    getPassPrompt = 'Enter teamcity password for user ' + username + ':'
    password = getpass.getpass(prompt=getPassPrompt )
    
    connect(username, password)
    
    buildTypeIds = get_generate_references_build_type_ids()
    
    for buildTypeId in buildTypeIds:
        remoteTests.start_build(username, xml_file_path, branch_name, git_path, tests_directory, buildTypeId)
    
    sleep(4)
    getBuildStatus.wait_for_running_builds(buildTypeIds)
示例#2
0
def get_generate_references_build_type_ids():
    build_types = getBuildStatus.get_build_types()
    dataString = str(build_types.read().decode())
    xmldata = ET.fromstring(dataString)
    build_type_ids = []

    for node in xmldata.iter():
        for buildType in node.findall('buildType'):
            buildTypeId = str(buildType.get('id'))
            if buildTypeId.find('Generate') != -1:
                build_type_ids.append(buildTypeId)

    return build_type_ids
示例#3
0
def start_build(username, password, xml_file_path, branch_name, git_path,
                tests_directory, buildTypeId):
    file = open(xml_file_path, 'rt')
    data = file.read()
    file.close()

    # insert branch name into
    xml = ET.fromstring(data)

    print('Starting remote build with id: ' + buildTypeId)

    # insert branch name into correct location
    for data in xml.iter():
        if data.get('branch'):
            data.set('branch', branch_name)
        if buildTypeId:
            if data.get('id'):
                data.set('id', buildTypeId)
        for param in data.findall('property'):
            if (param.get('name') == 'branchname'):
                param.set('value', branch_name)
            if param.get('name') == 'tests_directory':
                if tests_directory:
                    param.set('value', '--tests_directory ' + tests_directory)
            if (param.get('name') == 'vcsRoot'):
                # get vsc root list from teamcity
                # find id from config
                please = GetBuildStatus.get_vcs_instances()
                string = str(please.read().decode())
                vcs_xml = ET.fromstring(string)
                vcs_id = ''

                for node in vcs_xml.iter():
                    for instance in node.findall('vcs-root-instance'):
                        if instance.get('name').startswith(git_path):
                            vcs_id = instance.get('vcs-root-id')
                            set = True
                            break

                param.set('value', vcs_id)

    # convert back to string to be sent in post request
    xml_data = ET.tostring(xml)
    start_build_internal(username, password, xml_data)