00001
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
00027 HUDSON_UNRELEASED_CONFIG = """<?xml version='1.0' encoding='UTF-8'?>
00028 <project>
00029 <description>Unreleased 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>unreleased</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>
00054 BOOTSTRAP_SCRIPT
00055 rosrun job_generation run_auto_stack_unreleased.py --rosdistro ROSDISTRO
00056 SHUTDOWN_SCRIPT
00057 </command>
00058 </hudson.tasks.Shell>
00059 </builders>
00060 <publishers>
00061 <hudson.tasks.BuildTrigger>
00062 <childProjects>JOB_CHILDREN</childProjects>
00063 <threshold>
00064 <name>SUCCESS</name>
00065 <ordinal>0</ordinal>
00066 <color>BLUE</color>
00067 </threshold>
00068 </hudson.tasks.BuildTrigger>
00069 <hudson.tasks.junit.JUnitResultArchiver>
00070 <testResults>test_results/_hudson/*.xml</testResults>
00071 </hudson.tasks.junit.JUnitResultArchiver>
00072 <hudson.plugins.emailext.ExtendedEmailPublisher>
00073 <recipientList>EMAIL</recipientList>
00074 <configuredTriggers>
00075 EMAIL_TRIGGERS
00076 </configuredTriggers>
00077 <defaultSubject>$DEFAULT_SUBJECT</defaultSubject>
00078 <defaultContent>$DEFAULT_CONTENT
00079 
00080 <% 
00081 def ws = build.getParent().getWorkspace()
00082 def computer = build.getExecutor().getOwner()
00083 def build_failures = hudson.util.RemotingDiagnostics.executeGroovy("new File(\"${ws}/build_output/buildfailures.txt\").text",computer.getChannel())
00084 println "${build_failures}"
00085 def test_failures = hudson.util.RemotingDiagnostics.executeGroovy("new File(\"${ws}/test_output/testfailures.txt\").text",computer.getChannel())
00086 println "${test_failures}"
00087 def build_failures_context = hudson.util.RemotingDiagnostics.executeGroovy("new File(\"${ws}/build_output/buildfailures-with-context.txt\").text",computer.getChannel())
00088 println "${build_failures_context}"
00089 %></defaultContent>
00090 <defaultContentTypeHTML>false</defaultContentTypeHTML>
00091 <defaultContentIsScript>true</defaultContentIsScript>
00092 </hudson.plugins.emailext.ExtendedEmailPublisher>
00093 </publishers>
00094 <buildWrappers/>
00095 </project>
00096 """
00097
00098 import roslib; roslib.load_manifest("job_generation")
00099 from job_generation.jobs_common import *
00100 import yaml
00101
00102
00103 def unreleased_job_name(rosdistro, rosinstall, ubuntu, arch):
00104 return get_job_name('unreleased', rosdistro, rosinstall.split('/')[-1].split('.')[0], ubuntu, arch)
00105
00106
00107 def rosinstall_to_vcs(rosinstall):
00108 with open(rosinstall) as f:
00109 rosinstall = yaml.load(f.read())
00110 items = ''
00111 for r in rosinstall:
00112 item = HUDSON_SVN_ITEM
00113 item = item.replace('STACKNAME', r['svn']['local-name'])
00114 item = item.replace('STACKURI', r['svn']['uri'])
00115 items += item
00116 return HUDSON_SVN.replace('HUDSON_SVN_ITEMS', items)
00117
00118
00119
00120 def create_unreleased_configs(rosdistro, rosinstall):
00121
00122 gold_job = unreleased_job_name(rosdistro, rosinstall, UBUNTU_DISTRO_MAP[rosdistro][0], ARCHES[0])
00123 gold_children = [unreleased_job_name(rosdistro, rosinstall, u, a)
00124 for a in ARCHES for u in UBUNTU_DISTRO_MAP[rosdistro]]
00125 gold_children.remove(gold_job)
00126
00127
00128 configs = {}
00129 for ubuntudistro in UBUNTU_DISTRO_MAP[rosdistro]:
00130 for arch in ARCHES:
00131 name = unreleased_job_name(rosdistro, rosinstall, ubuntudistro, arch)
00132
00133
00134 time_trigger = ''
00135 job_children = ''
00136 if name == gold_job:
00137 time_trigger = '*/5 * * * *'
00138 job_children = ', '.join(gold_children)
00139
00140 hudson_config = HUDSON_UNRELEASED_CONFIG
00141 hudson_config = hudson_config.replace('BOOTSTRAP_SCRIPT', BOOTSTRAP_SCRIPT)
00142 hudson_config = hudson_config.replace('SHUTDOWN_SCRIPT', SHUTDOWN_SCRIPT)
00143 hudson_config = hudson_config.replace('EMAIL_TRIGGERS', get_email_triggers(['Unstable', 'Failure', 'StillFailing', 'Fixed', 'StillUnstable']))
00144 hudson_config = hudson_config.replace('UBUNTUDISTRO', ubuntudistro)
00145 hudson_config = hudson_config.replace('ARCH', arch)
00146 hudson_config = hudson_config.replace('ROSDISTRO', rosdistro)
00147 hudson_config = hudson_config.replace('HUDSON_VCS', rosinstall_to_vcs(rosinstall))
00148 hudson_config = hudson_config.replace('TIME_TRIGGER', time_trigger)
00149 hudson_config = hudson_config.replace('JOB_CHILDREN', job_children)
00150 hudson_config = hudson_config.replace('EMAIL', 'wim+unreleased@willowgarage.com')
00151 configs[name] = hudson_config
00152 return configs
00153
00154
00155
00156 def main():
00157 (options, args) = get_options(['rosdistro', 'rosinstall'], ['delete', 'wait'])
00158 if not options:
00159 return -1
00160
00161
00162 print 'Creating unreleased Hudson jobs:'
00163 unreleased_configs = create_unreleased_configs(options.rosdistro, options.rosinstall)
00164 schedule_jobs(unreleased_configs, options.wait, options.delete)
00165
00166
00167 if __name__ == '__main__':
00168 main()
00169
00170
00171
00172