def main():
    (options, args) = get_options(['stack', 'rosdistro', 'email'], ['repeat', 'source-only', 'arch', 'ubuntu', 'delete'])
    if not options:
        return -1

    try:
        # create hudson instance
        if len(args) == 2:
            hudson_instance = hudson.Hudson(SERVER, args[0], args[1])
        else:
            info = urllib.urlopen(CONFIG_PATH).read().split(',')
            hudson_instance = hudson.Hudson(SERVER, info[0], info[1])
        prerelease_configs = create_prerelease_configs(options.rosdistro, options.stack, options.email, options.repeat, options.source_only, options.arch, options.ubuntu)

        # check if jobs are not already running
        for job_name in prerelease_configs:
            exists = hudson_instance.job_exists(job_name)
            if exists and hudson_instance.job_is_running(job_name):
                print 'Cannot create job %s because a job with the same name is already running.'%job_name
                print 'Please try again when this job finished running.'
                return 

        # send prerelease tests to Hudson
        print 'Creating pre-release Hudson jobs:'
        schedule_jobs(prerelease_configs, start=True, hudson_obj=hudson_instance, delete=options.delete)
        if options.delete:
            print 'Jobs have been deleted. You can now start new jobs'
        else:
            print 'You will receive %d emails on %s, one for each job'%(len(prerelease_configs), options.email)
            print 'You can follow the progress of these jobs on <%s/view/pre-release>'%(SERVER)

    # catch all exceptions
    except Exception, e:
        print 'ERROR: Failed to communicate with Hudson server. Try again later.'
Exemple #2
0
def main():
    parser = optparse.OptionParser()
    parser.add_option('--delete',
                      dest='delete',
                      default=False,
                      action='store_true',
                      help='Delete jobs from Hudson')
    (options, args) = parser.parse_args()

    # hudson instance
    info = urllib.urlopen(CONFIG_PATH).read().split(',')
    hudson_instance = hudson.Hudson(SERVER, info[0], info[1])

    # send openni tests to Hudson
    print 'Creating openni Hudson jobs:'
    openni_configs = create_openni_configs()

    for job_name in openni_configs:
        exists = hudson_instance.job_exists(job_name)

        # delete job
        if options.delete and exists:
            print "Deleting job %s" % job_name
            hudson_instance.delete_job(job_name)

        # reconfigure job
        elif exists:
            print "  - %s" % job_name
            hudson_instance.reconfig_job(job_name, openni_configs[job_name])

        # create job
        elif not exists:
            print "  - %s" % job_name
            hudson_instance.create_job(job_name, openni_configs[job_name])
def trigger_hudson_source_deb(name, version, distro):
    h = hudson.Hudson(SERVER)
    parameters = {
        'DISTRO_NAME': distro.release_name,
        'STACK_NAME': name,
        'STACK_VERSION': version,
    }
    h.build_job('debbuild-sourcedeb',
                parameters=parameters,
                token='RELEASE_SOURCE_DEB')
def main():
    parser = optparse.OptionParser()
    parser.add_option('--delete',
                      dest='delete',
                      default=False,
                      action='store_true',
                      help='Delete jobs from Hudson')
    parser.add_option(
        '--rosinstall',
        dest='rosinstall',
        action='store',
        help="Specify the rosinstall file that refers to gazebo code.")
    parser.add_option(
        '--rosdistro',
        dest='rosdistro',
        action='store',
        help="Specify the ros distro to operate on (defaults to cturtle)")
    (options, args) = parser.parse_args()
    if not options.rosdistro:
        print 'Please provide the ros distro you want to test: --rosdistro cturtle'
        return
    if not options.rosdistro in UBUNTU_DISTRO_MAP.keys():
        print 'You profided an invalid "--rosdistro %s" argument. Options are %s' % (
            options.rosdistro, UBUNTU_DISTRO_MAP.keys())
        return
    if not options.rosinstall:
        print 'Please provide the rosinstall of gazebo code to test: --rosinstall foo.rosinstall'
        return

    # hudson instance
    info = urllib.urlopen(CONFIG_PATH).read().split(',')
    hudson_instance = hudson.Hudson(SERVER, info[0], info[1])

    # send gazebo tests to Hudson
    print 'Creating gazebo Hudson jobs:'
    gazebo_configs = create_gazebo_configs(options.rosdistro,
                                           options.rosinstall)

    for job_name in gazebo_configs:
        exists = hudson_instance.job_exists(job_name)

        # delete job
        if options.delete and exists:
            print "Deleting job %s" % job_name
            hudson_instance.delete_job(job_name)

        # reconfigure job
        elif exists:
            print "  - %s" % job_name
            hudson_instance.reconfig_job(job_name, gazebo_configs[job_name])

        # create job
        elif not exists:
            print "  - %s" % job_name
            hudson_instance.create_job(job_name, gazebo_configs[job_name])
def trigger_debs(distro, os_platform, arch):
    h = hudson.Hudson(SERVER)
    parameters = {
        'DISTRO_NAME': distro,
        'STACK_NAME': 'ALL',
        'OS_PLATFORM': os_platform,
        'ARCH': arch,
    }
    h.build_job('debbuild-build-debs-%s-%s-%s' % (distro, os_platform, arch),
                parameters=parameters,
                token='RELEASE_BUILD_DEBS')
def trigger_hudson_build_debs(name, distro_name, os_platform):
    if distro_name != 'electric':
        return
    import hudson
    h = hudson.Hudson(SERVER)
    parameters = {
        'DISTRO_NAME': distro_name,
        'STACK_NAME': name,
        'OS_PLATFORM': os_platform,
    }
    for arch in ['i386', 'amd64']:
        parameters['ARCH'] = arch
        h.build_job('debbuild-build-debs-%s-%s-%s' %
                    (distro_name, os_platform, arch),
                    parameters=parameters,
                    token='RELEASE_BUILD_DEBS')
Exemple #7
0
def schedule_jobs(jobs,
                  wait=False,
                  delete=False,
                  start=False,
                  hudson_obj=None):
    # create hudson instance
    if not hudson_obj:
        info = urllib.urlopen(CONFIG_PATH).read().split(',')
        hudson_obj = hudson.Hudson(SERVER, info[0], info[1])

    finished = False
    while not finished:
        jobs_todo = {}
        for job_name in jobs:
            exists = hudson_obj.job_exists(job_name)

            # job is already running
            if exists and hudson_obj.job_is_running(job_name):
                jobs_todo[job_name] = jobs[job_name]
                print "Not reconfiguring running job %s because it is still running" % job_name

            # delete old job
            elif delete:
                if exists:
                    hudson_obj.delete_job(job_name)
                    print " - Deleting job %s" % job_name

            # reconfigure job
            elif exists:
                hudson_obj.reconfig_job(job_name, jobs[job_name])
                if start:
                    hudson_obj.build_job(job_name)
                print " - %s" % job_name

            # create job
            elif not exists:
                hudson_obj.create_job(job_name, jobs[job_name])
                if start:
                    hudson_obj.build_job(job_name)
                print " - %s" % job_name

        if wait and len(jobs_todo) > 0:
            jobs = jobs_todo
            jobs_todo = {}
            time.sleep(10.0)
        else:
            finished = True
Exemple #8
0
def main():
    if len(sys.argv) == 4:
        username = sys.argv[1]
        password = sys.argv[2]
    elif len(sys.argv) == 1:
        username = password = None
    else:
        if len(sys.argv) != 4:
            print "Usage: job_generator.py [username] [password] stack"
            sys.exit(1)

    hudson_instance = hudson.Hudson(SERVER, username, password)
    job_name = sys.argv[3] + "_auto_trunk_test"

    if hudson_instance.job_exists(job_name):
        hudson_instance.delete_job(job_name)
    hudson_instance.create_job(job_name, EMPTY_CONFIG_XML)
Exemple #9
0
def generate_allhtml_report(output, distro_name, os_platforms):
    import hudson
    h = hudson.Hudson(HUDSON)
    distro = load_distro(distro_name)

    main_repo = {}
    arches = ARCHES
    for os_platform in os_platforms:
        for arch in arches:
            try:
                main_repo["%s-%s" % (os_platform, arch)] = load_Packages(
                    ROS_REPO, os_platform, arch)
            except:
                main_repo["%s-%s" % (os_platform, arch)] = []

    fixed_repo = {}
    arches = ARCHES
    for os_platform in os_platforms:
        for arch in arches:
            try:
                fixed_repo["%s-%s" % (os_platform, arch)] = load_Packages(
                    SHADOW_FIXED_REPO, os_platform, arch)
            except:
                fixed_repo["%s-%s" % (os_platform, arch)] = []

    missing_primary = None
    missing_dep = None

    counts = {}
    stacks = {}
    for stack in distro.stacks.keys():
        stacks[stack] = {}

    for os_platform in os_platforms:
        for arch in arches:
            key = "%s-%s" % (os_platform, arch)
            try:
                missing_primary, missing_dep, missing_excluded, missing_excluded_dep = get_missing(
                    distro, os_platform, arch)
            except BadRepo:
                for s in distro.stacks.iterkeys():
                    stacks[s][key] = MISSING_REPO
                counts[key] = "!"
                continue

            args = get_missing(distro, os_platform, arch)
            try:
                args_fixed = get_missing(distro,
                                         os_platform,
                                         arch,
                                         repo=SHADOW_FIXED_REPO,
                                         lock_version=False)
            except BadRepo:
                for s in distro.stacks.iterkeys():
                    stacks[s][key] = MISSING_REPO
                counts[key] = "!"
                continue
            counts[key] = ','.join([str(len(x)) for x in args])
            missing_primary, missing_dep, missing_excluded, missing_excluded_dep = args
            missing_primary_fixed, missing_dep_fixed, missing_excluded_fixed, missing_excluded_dep_fixed = args_fixed
            for s in missing_primary:
                if svn_url_exists(sourcedeb_url(distro, s, os_platform)):
                    stacks[s][key] = MISSING_PRIMARY
                else:
                    stacks[s][key] = MISSING_SOURCEDEB
            for s in missing_dep:
                if svn_url_exists(sourcedeb_url(distro, s, os_platform)):
                    stacks[s][key] = MISSING_DEP
                else:
                    stacks[s][key] = MISSING_SOURCEDEB
            for s in missing_primary_fixed:
                if svn_url_exists(sourcedeb_url(distro, s, os_platform)):
                    stacks[s][key] = MISSING_BROKEN
                else:
                    stacks[s][key] = MISSING_SOURCEDEB
            for s in missing_dep_fixed:
                if svn_url_exists(sourcedeb_url(distro, s, os_platform)):
                    stacks[s][key] = MISSING_BROKEN_DEP
                else:
                    stacks[s][key] = MISSING_SOURCEDEB

            for s in missing_excluded:
                stacks[s][key] = MISSING_EXCLUDED
            for s in missing_excluded_dep:
                stacks[s][key] = MISSING_EXCLUDED_DEP

    with open(output, 'w') as f:
        f.write(get_html_header(distro_name))
        f.write(get_html_repository_status(distro, os_platforms, arches))
        f.write(get_html_legend())
        job = 'debbuild-build-debs'
        f.write(
            get_html_table_header(h, distro_name, os_platforms, arches, counts,
                                  job))

        stack_names = sorted(stacks.keys())
        for stack in stack_names:

            d = stacks[stack]
            shadow_version = distro.stacks[stack].version

            # generate URL
            stack_name = stack
            stack_version = shadow_version
            url = SOURCEDEB_DIR_URI % locals()

            # MISSING_SOURCEDEB is os/arch independent, so treat row as a whole
            sample_key = "%s-%s" % (os_platforms[0], arches[0])
            if sample_key in d and d[sample_key] == MISSING_SOURCEDEB:
                color = COLORS[d[sample_key]]
                job_url = sourcedeb_job_url(h, distro_name, stack,
                                            shadow_version)
                f.write(
                    '<tr><td bgcolor="%s"><a href="%s">%s %s</a> <a href="%s">[+]</a></td>'
                    % (color, url, stack, shadow_version, job_url))
            else:
                if 0:
                    f.write('<tr><td><a href="%s">%s %s</a></td>' %
                            (url, stack, shadow_version))
                else:
                    job_url = sourcedeb_job_url(h, distro_name, stack,
                                                shadow_version)
                    # temporarily including [+] for all right now to help bringup maverick
                    f.write(
                        '<tr><td><a href="%s">%s %s</a> <a href="%s">[+]</a></td>'
                        % (url, stack, shadow_version, job_url))

            for os_platform in os_platforms:
                for arch in arches:
                    key = "%s-%s" % (os_platform, arch)

                    # compute version in actual repo
                    version_str = ''
                    try:
                        main_match = get_stack_version(main_repo[key],
                                                       distro_name, stack)
                        fixed_match = get_stack_version(
                            fixed_repo[key], distro_name, stack)
                        if main_match != shadow_version or fixed_match != shadow_version:
                            main_match = main_match or '0'
                            fixed_match = fixed_match or '0'
                            version_str = '<em>' + str(
                                fixed_match) + ', ' + str(main_match) + '</em>'
                    except Exception, e:
                        print str(e)

                    if key in d:
                        val = d[key]
                        color = COLORS[val]
                        params = {'STACK_NAME': stack}
                        if val == MISSING_SOURCEDEB:
                            f.write('<td bgcolor="%s">%s %s</td>' %
                                    (color, val, version_str))
                        else:
                            url = h.build_job_url(
                                '%s-%s-%s-%s' %
                                (job, distro_name, os_platform, arch),
                                parameters=params)
                            f.write(
                                '<td bgcolor="%s">%s <a href="%s">[+]</a> %s</td>'
                                % (color, val, url, version_str))
                    else:
                        f.write('<td>&nbsp;%s </td>' % version_str)
            f.write('</tr>\n')

        f.write('\n</table></body></html>')
import roslib; roslib.load_manifest('job_generation')

import os
import sys

import roslib.packages
import rosdeb.targets
import hudson

if not len(sys.argv) == 4:
    print "Usage: create_distro <distro> <username> <password>"
    sys.exit(1)

_, distro, username, password = sys.argv

h = hudson.Hudson('http://build.willowgarage.com', username, password)

d = os.path.join(roslib.packages.get_pkg_dir('job_generation'), 'scripts')

with open(os.path.join(d, 'debbuild-build-debs.xml'), 'r') as f:
    config_xml = f.read()

os_repl = 'lucid'
arch_repl = 'amd64'

if not distro in rosdeb.targets.os_platform:
    raise Exception("Please update rosdeb.target.os_platform with key [%s]"%(distro))
platforms = rosdeb.targets.os_platform[distro]
for osp in platforms:
    for arch in ['i386', 'amd64']:
        job_xml = config_xml.replace(os_repl, osp).replace(arch_repl, arch)