$search
00001 #!/usr/bin/python 00002 00003 00004 HUDSON_SVN_ITEM = """ 00005 <hudson.scm.SubversionSCM_-ModuleLocation> 00006 <remote>STACKURI</remote> 00007 <local>STACKNAME</local> 00008 </hudson.scm.SubversionSCM_-ModuleLocation> 00009 """ 00010 00011 HUDSON_SVN = """ 00012 <scm class="hudson.scm.SubversionSCM"> 00013 <locations> 00014 HUDSON_SVN_ITEMS 00015 </locations> 00016 <useUpdate>false</useUpdate> 00017 <doRevert>false</doRevert> 00018 <excludedRegions></excludedRegions> 00019 <includedRegions></includedRegions> 00020 <excludedUsers></excludedUsers> 00021 <excludedRevprop></excludedRevprop> 00022 <excludedCommitMessages></excludedCommitMessages> 00023 </scm> 00024 """ 00025 00026 # template to create gazebo hudson configuration file 00027 HUDSON_GAZEBO_CONFIG = """<?xml version='1.0' encoding='UTF-8'?> 00028 <project> 00029 <description>Gazebo build of NAME for ROSDISTRO on UBUNTUDISTRO, ARCH</description> 00030 <logRotator> 00031 <daysToKeep>5</daysToKeep> 00032 <numToKeep>-1</numToKeep> 00033 </logRotator> 00034 <keepDependencies>false</keepDependencies> 00035 <properties> 00036 <hudson.plugins.trac.TracProjectProperty> 00037 <tracWebsite>http://code.ros.org/trac/ros/</tracWebsite> 00038 </hudson.plugins.trac.TracProjectProperty> 00039 </properties> 00040 HUDSON_VCS 00041 <assignedNode>gazebo</assignedNode> 00042 <canRoam>false</canRoam> 00043 <disabled>false</disabled> 00044 <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding> 00045 <triggers class="vector"> 00046 <hudson.triggers.SCMTrigger> 00047 <spec>TIME_TRIGGER</spec> 00048 </hudson.triggers.SCMTrigger> 00049 </triggers> 00050 <concurrentBuild>false</concurrentBuild> 00051 <builders> 00052 <hudson.tasks.Shell> 00053 <command>cat > $WORKSPACE/script.sh <<DELIM 00054 #!/usr/bin/env bash 00055 set -o errexit 00056 echo "_________________________________BEGIN SCRIPT______________________________________" 00057 BOOTSTRAP_SCRIPT 00058 rosrun job_generation run_auto_stack_gazebo.py --rosdistro ROSDISTRO 00059 echo "_________________________________END SCRIPT_______________________________________" 00060 DELIM 00061 00062 set -o errexit 00063 00064 rm -rf $WORKSPACE/test_results 00065 rm -rf $WORKSPACE/test_output 00066 00067 wget --no-check-certificate https://code.ros.org/svn/ros/stacks/ros_release/trunk/hudson/scripts/run_chroot.py -O $WORKSPACE/run_chroot.py 00068 chmod +x $WORKSPACE/run_chroot.py 00069 cd $WORKSPACE && $WORKSPACE/run_chroot.py --distro=UBUNTUDISTRO --arch=ARCH --ramdisk --script=$WORKSPACE/script.sh 00070 </command> 00071 </hudson.tasks.Shell> 00072 </builders> 00073 <publishers> 00074 <hudson.tasks.BuildTrigger> 00075 <childProjects>JOB_CHILDREN</childProjects> 00076 <threshold> 00077 <name>SUCCESS</name> 00078 <ordinal>0</ordinal> 00079 <color>BLUE</color> 00080 </threshold> 00081 </hudson.tasks.BuildTrigger> 00082 <hudson.tasks.junit.JUnitResultArchiver> 00083 <testResults>test_results/_hudson/*.xml</testResults> 00084 </hudson.tasks.junit.JUnitResultArchiver> 00085 <hudson.plugins.emailext.ExtendedEmailPublisher> 00086 <recipientList>EMAIL</recipientList> 00087 <configuredTriggers> 00088 <hudson.plugins.emailext.plugins.trigger.UnstableTrigger> 00089 <email> 00090 <recipientList></recipientList> 00091 <subject>$PROJECT_DEFAULT_SUBJECT</subject> 00092 <body>$PROJECT_DEFAULT_CONTENT</body> 00093 <sendToDevelopers>true</sendToDevelopers> 00094 <sendToRecipientList>true</sendToRecipientList> 00095 <contentTypeHTML>false</contentTypeHTML> 00096 <script>true</script> 00097 </email> 00098 </hudson.plugins.emailext.plugins.trigger.UnstableTrigger> 00099 <hudson.plugins.emailext.plugins.trigger.FailureTrigger> 00100 <email> 00101 <recipientList></recipientList> 00102 <subject>$PROJECT_DEFAULT_SUBJECT</subject> 00103 <body>$PROJECT_DEFAULT_CONTENT</body> 00104 <sendToDevelopers>true</sendToDevelopers> 00105 <sendToRecipientList>true</sendToRecipientList> 00106 <contentTypeHTML>false</contentTypeHTML> 00107 <script>true</script> 00108 </email> 00109 </hudson.plugins.emailext.plugins.trigger.FailureTrigger> 00110 <hudson.plugins.emailext.plugins.trigger.StillFailingTrigger> 00111 <email> 00112 <recipientList></recipientList> 00113 <subject>$PROJECT_DEFAULT_SUBJECT</subject> 00114 <body>$PROJECT_DEFAULT_CONTENT</body> 00115 <sendToDevelopers>true</sendToDevelopers> 00116 <sendToRecipientList>true</sendToRecipientList> 00117 <contentTypeHTML>false</contentTypeHTML> 00118 <script>true</script> 00119 </email> 00120 </hudson.plugins.emailext.plugins.trigger.StillFailingTrigger> 00121 <hudson.plugins.emailext.plugins.trigger.FixedTrigger> 00122 <email> 00123 <recipientList></recipientList> 00124 <subject>$PROJECT_DEFAULT_SUBJECT</subject> 00125 <body>$PROJECT_DEFAULT_CONTENT</body> 00126 <sendToDevelopers>true</sendToDevelopers> 00127 <sendToRecipientList>true</sendToRecipientList> 00128 <contentTypeHTML>false</contentTypeHTML> 00129 <script>true</script> 00130 00131 </email> 00132 </hudson.plugins.emailext.plugins.trigger.FixedTrigger> 00133 <hudson.plugins.emailext.plugins.trigger.StillUnstableTrigger> 00134 <email> 00135 <recipientList></recipientList> 00136 <subject>$PROJECT_DEFAULT_SUBJECT</subject> 00137 <body>$PROJECT_DEFAULT_CONTENT</body> 00138 <sendToDevelopers>true</sendToDevelopers> 00139 <sendToRecipientList>true</sendToRecipientList> 00140 <contentTypeHTML>false</contentTypeHTML> 00141 <script>true</script> 00142 </email> 00143 </hudson.plugins.emailext.plugins.trigger.StillUnstableTrigger> 00144 </configuredTriggers> 00145 <defaultSubject>$DEFAULT_SUBJECT</defaultSubject> 00146 <defaultContent>$DEFAULT_CONTENT
 00147 
 00148 <% 
 00149 def ws = build.getParent().getWorkspace()
 00150 def computer = build.getExecutor().getOwner()
 00151 def build_failures = hudson.util.RemotingDiagnostics.executeGroovy("new File(\"${ws}/build_output/buildfailures.txt\").text",computer.getChannel())
 00152 println "${build_failures}"
 00153 def test_failures = hudson.util.RemotingDiagnostics.executeGroovy("new File(\"${ws}/test_output/testfailures.txt\").text",computer.getChannel())
 00154 println "${test_failures}"
 00155 def build_failures_context = hudson.util.RemotingDiagnostics.executeGroovy("new File(\"${ws}/build_output/buildfailures-with-context.txt\").text",computer.getChannel())
 00156 println "${build_failures_context}"
 00157 %></defaultContent> 00158 <defaultContentTypeHTML>false</defaultContentTypeHTML> 00159 <defaultContentIsScript>true</defaultContentIsScript> 00160 </hudson.plugins.emailext.ExtendedEmailPublisher> 00161 </publishers> 00162 <buildWrappers/> 00163 </project> 00164 """ 00165 00166 import roslib; roslib.load_manifest("job_generation") 00167 from job_generation.jobs_common import * 00168 import hudson 00169 import urllib 00170 import optparse 00171 import yaml 00172 00173 00174 def gazebo_job_name(rosdistro, rosinstall, ubuntudistro, arch): 00175 return "_".join(['gazebo', rosdistro, rosinstall.split('/')[-1].split('.')[0], ubuntudistro, arch]) 00176 00177 00178 def rosinstall_to_vcs(rosinstall): 00179 with open(rosinstall) as f: 00180 rosinstall = yaml.load(f.read()) 00181 items = '' 00182 for r in rosinstall: 00183 item = HUDSON_SVN_ITEM 00184 item = item.replace('STACKNAME', r['svn']['local-name']) 00185 item = item.replace('STACKURI', r['svn']['uri']) 00186 items += item 00187 return HUDSON_SVN.replace('HUDSON_SVN_ITEMS', items) 00188 00189 00190 00191 def create_gazebo_configs(rosdistro, rosinstall): 00192 # create gold distro 00193 gold_job = gazebo_job_name(rosdistro, rosinstall, UBUNTU_DISTRO_MAP[rosdistro][0], ARCHES[0]) 00194 gold_children = [gazebo_job_name(rosdistro, rosinstall, u, a) 00195 for a in ARCHES for u in UBUNTU_DISTRO_MAP[rosdistro]] 00196 gold_children.remove(gold_job) 00197 00198 # create hudson config files for each ubuntu distro 00199 configs = {} 00200 for ubuntudistro in UBUNTU_DISTRO_MAP[rosdistro]: 00201 for arch in ARCHES: 00202 name = gazebo_job_name(rosdistro, rosinstall, ubuntudistro, arch) 00203 00204 # check if this is the 'gold' job 00205 time_trigger = '' 00206 job_children = '' 00207 if name == gold_job: 00208 time_trigger = '*/5 * * * *' 00209 job_children = ', '.join(gold_children) 00210 00211 hudson_config = HUDSON_GAZEBO_CONFIG 00212 hudson_config = hudson_config.replace('BOOTSTRAP_SCRIPT', BOOTSTRAP_SCRIPT) 00213 hudson_config = hudson_config.replace('UBUNTUDISTRO', ubuntudistro) 00214 hudson_config = hudson_config.replace('ARCH', arch) 00215 hudson_config = hudson_config.replace('ROSDISTRO', rosdistro) 00216 hudson_config = hudson_config.replace('HUDSON_VCS', rosinstall_to_vcs(rosinstall)) 00217 hudson_config = hudson_config.replace('TIME_TRIGGER', time_trigger) 00218 hudson_config = hudson_config.replace('JOB_CHILDREN', job_children) 00219 hudson_config = hudson_config.replace('EMAIL', 'wim+gazebo@willowgarage.com') 00220 configs[name] = hudson_config 00221 return configs 00222 00223 00224 00225 def main(): 00226 parser = optparse.OptionParser() 00227 parser.add_option('--delete', dest = 'delete', default=False, action='store_true', 00228 help='Delete jobs from Hudson') 00229 parser.add_option('--rosinstall', dest = 'rosinstall', action='store', 00230 help="Specify the rosinstall file that refers to gazebo code.") 00231 parser.add_option('--rosdistro', dest = 'rosdistro', action='store', 00232 help="Specify the ros distro to operate on (defaults to cturtle)") 00233 (options, args) = parser.parse_args() 00234 if not options.rosdistro: 00235 print 'Please provide the ros distro you want to test: --rosdistro cturtle' 00236 return 00237 if not options.rosdistro in UBUNTU_DISTRO_MAP.keys(): 00238 print 'You profided an invalid "--rosdistro %s" argument. Options are %s'%(options.rosdistro, UBUNTU_DISTRO_MAP.keys()) 00239 return 00240 if not options.rosinstall: 00241 print 'Please provide the rosinstall of gazebo code to test: --rosinstall foo.rosinstall' 00242 return 00243 00244 00245 # hudson instance 00246 info = urllib.urlopen(CONFIG_PATH).read().split(',') 00247 hudson_instance = hudson.Hudson(SERVER, info[0], info[1]) 00248 00249 # send gazebo tests to Hudson 00250 print 'Creating gazebo Hudson jobs:' 00251 gazebo_configs = create_gazebo_configs(options.rosdistro, options.rosinstall) 00252 00253 for job_name in gazebo_configs: 00254 exists = hudson_instance.job_exists(job_name) 00255 00256 # delete job 00257 if options.delete and exists: 00258 print "Deleting job %s"%job_name 00259 hudson_instance.delete_job(job_name) 00260 00261 # reconfigure job 00262 elif exists: 00263 print " - %s"%job_name 00264 hudson_instance.reconfig_job(job_name, gazebo_configs[job_name]) 00265 00266 # create job 00267 elif not exists: 00268 print " - %s"%job_name 00269 hudson_instance.create_job(job_name, gazebo_configs[job_name]) 00270 00271 00272 00273 if __name__ == '__main__': 00274 main() 00275 00276 00277 00278