$search
00001 #!/usr/bin/python 00002 00003 # template to create develop hudscon configuration file 00004 HUDSON_DEVEL_CONFIG = """<?xml version='1.0' encoding='UTF-8'?> 00005 <project> 00006 <description>Build of STACKNAME development branch for ROSDISTRO on UBUNTUDISTRO, ARCH</description> 00007 <logRotator> 00008 <daysToKeep>180</daysToKeep> 00009 <numToKeep>-1</numToKeep> 00010 </logRotator> 00011 <keepDependencies>false</keepDependencies> 00012 <properties> 00013 <hudson.plugins.trac.TracProjectProperty> 00014 <tracWebsite>http://code.ros.org/trac/ros/</tracWebsite> 00015 </hudson.plugins.trac.TracProjectProperty> 00016 </properties> 00017 HUDSON_VCS 00018 <assignedNode>NODE</assignedNode> 00019 <canRoam>false</canRoam> 00020 <disabled>false</disabled> 00021 <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding> 00022 <triggers class="vector"> 00023 <hudson.triggers.SCMTrigger> 00024 <spec>TIME_TRIGGER</spec> 00025 </hudson.triggers.SCMTrigger> 00026 </triggers> 00027 <concurrentBuild>false</concurrentBuild> 00028 <builders> 00029 <hudson.tasks.Shell> 00030 <command> 00031 BOOTSTRAP_SCRIPT 00032 rosrun job_generation run_auto_stack_devel.py --stack STACKNAME --rosdistro ROSDISTRO --repeat 0 SOURCE_ONLY 00033 SHUTDOWN_SCRIPT 00034 </command> 00035 </hudson.tasks.Shell> 00036 </builders> 00037 <publishers> 00038 <hudson.tasks.BuildTrigger> 00039 <childProjects>JOB_CHILDREN</childProjects> 00040 <threshold> 00041 <name>SUCCESS</name> 00042 <ordinal>0</ordinal> 00043 <color>BLUE</color> 00044 </threshold> 00045 </hudson.tasks.BuildTrigger> 00046 <hudson.tasks.junit.JUnitResultArchiver> 00047 <testResults>test_results/**/_hudson/*.xml</testResults> 00048 </hudson.tasks.junit.JUnitResultArchiver> 00049 <hudson.plugins.emailext.ExtendedEmailPublisher> 00050 <recipientList>EMAIL</recipientList> 00051 <configuredTriggers> 00052 EMAIL_TRIGGERS 00053 </configuredTriggers> 00054 <defaultSubject>$DEFAULT_SUBJECT</defaultSubject> 00055 <defaultContent>$DEFAULT_CONTENT
 00056 
 00057 <% 
 00058 def ws = build.getParent().getWorkspace()
 00059 def computer = build.getExecutor().getOwner()
 00060 def build_failures = hudson.util.RemotingDiagnostics.executeGroovy("new File(\"${ws}/build_output/buildfailures.txt\").text",computer.getChannel())
 00061 println "${build_failures}"
 00062 def test_failures = hudson.util.RemotingDiagnostics.executeGroovy("new File(\"${ws}/test_output/testfailures.txt\").text",computer.getChannel())
 00063 println "${test_failures}"
 00064 def build_failures_context = hudson.util.RemotingDiagnostics.executeGroovy("new File(\"${ws}/build_output/buildfailures-with-context.txt\").text",computer.getChannel())
 00065 println "${build_failures_context}"
 00066 %></defaultContent> 00067 <defaultContentTypeHTML>false</defaultContentTypeHTML> 00068 <defaultContentIsScript>true</defaultContentIsScript> 00069 </hudson.plugins.emailext.ExtendedEmailPublisher> 00070 </publishers> 00071 <buildWrappers/> 00072 </project> 00073 """ 00074 00075 00076 import roslib; roslib.load_manifest("job_generation") 00077 import rosdistro 00078 from job_generation.jobs_common import * 00079 00080 00081 def devel_job_name(rosdistro, stack_name, ubuntu, arch): 00082 return get_job_name('devel', rosdistro, stack_name, ubuntu, arch) 00083 00084 00085 def create_devel_configs(os, rosdistro, stack): 00086 dist_arch = [] 00087 if os == 'ubuntu': 00088 for ubuntudistro in UBUNTU_DISTRO_MAP[rosdistro]: 00089 for arch in ARCHES: 00090 dist_arch.append((ubuntudistro, arch)) 00091 bootstrap_script = BOOTSTRAP_SCRIPT 00092 shutdown_script = SHUTDOWN_SCRIPT 00093 source_only = '' 00094 node = 'devel' 00095 elif os == 'osx': 00096 dist_arch.append(('osx', 'amd64')) 00097 bootstrap_script = BOOTSTRAP_SCRIPT_OSX 00098 shutdown_script = SHUTDOWN_SCRIPT_OSX 00099 source_only = '--source-only' 00100 node = 'osx10_5_vnc' 00101 00102 # create gold distro 00103 gold_children = [devel_job_name(rosdistro, stack.name, u, a) for (u, a) in dist_arch] 00104 gold_job = gold_children[0] 00105 gold_children.remove(gold_job) 00106 00107 # create hudson config files for each ubuntu distro 00108 configs = {} 00109 for (osdistro, arch) in dist_arch: 00110 name = devel_job_name(rosdistro, stack.name, osdistro, arch) 00111 00112 # create VCS block 00113 if stack.vcs_config.type in hudson_scm_managers: 00114 hudson_vcs = hudson_scm_managers[stack.vcs_config.type] 00115 else: 00116 raise NotImplementedError("vcs type %s not implemented as hudson scm manager"%stack.vcs_config.type) 00117 00118 00119 if stack.vcs_config.type in ['svn']: 00120 hudson_vcs = hudson_vcs.replace('STACKNAME', stack.name) 00121 hudson_vcs = hudson_vcs.replace('STACKURI', stack.vcs_config.anon_dev) 00122 elif stack.vcs_config.type in ['git', 'hg', 'bzr']: 00123 hudson_vcs = hudson_vcs.replace('STACKBRANCH', stack.vcs_config.dev_branch) 00124 hudson_vcs = hudson_vcs.replace('STACKURI', stack.vcs_config.anon_repo_uri) 00125 hudson_vcs = hudson_vcs.replace('STACKNAME', stack.name) 00126 else: 00127 print "UNSUPPORTED VCS TYPE" 00128 raise 00129 00130 # check if this is the 'gold' job 00131 time_trigger = '' 00132 job_children = '' 00133 if name == gold_job: 00134 time_trigger = '*/5 * * * *' 00135 job_children = ', '.join(gold_children) 00136 00137 hudson_config = HUDSON_DEVEL_CONFIG 00138 hudson_config = hudson_config.replace('SOURCE_ONLY', source_only) 00139 hudson_config = hudson_config.replace('BOOTSTRAP_SCRIPT', bootstrap_script) 00140 hudson_config = hudson_config.replace('SHUTDOWN_SCRIPT', shutdown_script) 00141 hudson_config = hudson_config.replace('EMAIL_TRIGGERS', get_email_triggers(['Unstable', 'Failure', 'Fixed'])) 00142 hudson_config = hudson_config.replace('UBUNTUDISTRO', osdistro) 00143 hudson_config = hudson_config.replace('ARCH', arch) 00144 hudson_config = hudson_config.replace('ROSDISTRO', rosdistro) 00145 hudson_config = hudson_config.replace('STACKNAME', stack.name) 00146 hudson_config = hudson_config.replace('HUDSON_VCS', hudson_vcs) 00147 hudson_config = hudson_config.replace('TIME_TRIGGER', time_trigger) 00148 hudson_config = hudson_config.replace('JOB_CHILDREN', job_children) 00149 hudson_config = hudson_config.replace('EMAIL', 'rosrelease-devel@kforge.ros.org') 00150 hudson_config = hudson_config.replace('NODE', node) 00151 configs[name] = hudson_config 00152 return configs 00153 00154 00155 00156 00157 def main(): 00158 (options, args) = get_options(['rosdistro'], ['delete', 'wait', 'stack', 'os']) 00159 if not options: 00160 return -1 00161 00162 # generate hudson config files 00163 distro_obj = rosdistro.Distro(get_rosdistro_file(options.rosdistro)) 00164 if options.stack: 00165 stack_list = options.stack 00166 for s in stack_list: 00167 if not s in distro_obj.released_stacks: 00168 if s in distro_obj.stacks: 00169 print "Stack %s is in rosdistro file, but it is not yet released (version is set to 'null'"%s 00170 else: 00171 print "Stack %s is not in rosdistro file"%s 00172 return 00173 else: 00174 stack_list = distro_obj.released_stacks 00175 devel_configs = {} 00176 for stack_name in stack_list: 00177 devel_configs.update(create_devel_configs(options.os, distro_obj.release_name, distro_obj.stacks[stack_name])) 00178 00179 # schedule jobs 00180 schedule_jobs(devel_configs, options.wait, options.delete) 00181 00182 00183 if __name__ == '__main__': 00184 main() 00185 00186 00187 00188