Пример #1
0
def get_version_from_artifacts(jenkins_build_data):
    if not any([artifact for artifact in jenkins_build_data['artifacts']
               if artifact['fileName'] == JENKINS['magnet_link_artifact']]):
        return
    iso_link = (get_build_artifact(url=jenkins_build_data['url'],
                                   artifact=JENKINS['magnet_link_artifact']))
    if iso_link:
        return get_version_from_iso_name(iso_link)
Пример #2
0
def get_version_from_artifacts(jenkins_build_data):
    if not any([artifact for artifact in jenkins_build_data['artifacts']
               if artifact['fileName'] == JENKINS['magnet_link_artifact']]):
        return
    iso_link = (get_build_artifact(url=jenkins_build_data['url'],
                                   artifact=JENKINS['magnet_link_artifact']))
    if iso_link:
        return get_version_from_iso_name(iso_link)
Пример #3
0
def get_build_test_data(build_number, job_name,
                        jenkins_url=JENKINS.get('url')):
    """ Get build test data from Jenkins from nosetests.xml

    :param build_number: int - Jenkins build number
    :param job_name: str - Jenkins job_name
    :param jenkins_url: str - Jenkins http url
    :return: test_data: dict - build info or None otherwise
    """

    test_data = None
    logger.info('Getting subbuild {} {}'.format(job_name, build_number))
    runner_build = Build(job_name, build_number)
    buildinfo = runner_build.get_build_data(depth=0)
    if not buildinfo:
        logger.error('Getting subbuilds info is failed. '
                     'Job={} Build={}'.format(job_name, build_number))
        return test_data
    try:
        artifact_paths = [
            v for i in buildinfo.get('artifacts') for k, v in i.items()
            if k == 'relativePath'
            and v == JENKINS.get('xml_testresult_file_name')
        ][0]
        artifact_url = "/".join(
            [jenkins_url, 'job', job_name,
             str(build_number)])
        xdata = get_build_artifact(artifact_url, artifact_paths)
        test_data = xmltodict.parse(xdata, xml_attribs=True)
        test_data.update({
            'build_number': build_number,
            'job_name': job_name,
            'job_url': buildinfo.get('url'),
            'job_description': buildinfo.get('description'),
            'job_status': buildinfo.get('result')
        })
    except:
        test_data = None
    return test_data
def get_build_test_data(build_number, job_name,
                        jenkins_url=JENKINS.get('url')):
    """ Get build test data from Jenkins from nosetests.xml

    :param build_number: int - Jenkins build number
    :param job_name: str - Jenkins job_name
    :param jenkins_url: str - Jenkins http url
    :return: test_data: dict - build info or None otherwise
    """

    test_data = None
    logger.info('Getting subbuild {} {}'.format(job_name,
                                                build_number))
    runner_build = Build(job_name, build_number)
    buildinfo = runner_build.get_build_data(depth=0)
    if not buildinfo:
        logger.error('Getting subbuilds info is failed. '
                     'Job={} Build={}'.format(job_name, build_number))
        return test_data
    try:
        artifact_paths = [v for i in buildinfo.get('artifacts')
                          for k, v in i.items() if k == 'relativePath' and
                          v == JENKINS.get('xml_testresult_file_name')][0]
        artifact_url = "/".join([jenkins_url, 'job', job_name,
                                 str(build_number)])
        xdata = get_build_artifact(artifact_url, artifact_paths)
        test_data = xmltodict.parse(xdata, xml_attribs=True)
        test_data.update({'build_number': build_number,
                          'job_name': job_name,
                          'job_url': buildinfo.get('url'),
                          'job_description':
                              buildinfo.get('description'),
                          'job_status': buildinfo.get('result')})
    except:
        test_data = None
    return test_data