Ejemplo n.º 1
0
  def post(self, project_key):
    token = self.request.get('token')
    logging.info('token is %s' % token)
    if token != self.project.continuous_token:
      self.access_denied("Invalid token", attemp_login = False)
      
    builder = self.project.continuous_builder
    logging.info('token ok; builder is %s' % builder)
    if builder == None:
      self.not_found("Continuous builds are disabled for this project")

    latest_build = self.project.builds.order('-created_at').get()
    version = calculate_next_version(latest_build)
    logging.info('builder ok; version is %s' % version)

    existing_count = self.project.builds.filter('version =', version).count()
    if existing_count > 0:
      logging.info("Ignoring build request with the same version number (%s, project %s)" % (version, self.project.name))
      self.error(400)
      return
      
    script_info = self.project.script_info()
    repo_configuration = repo_configuration_info()
    for repos in script_info.alternable_repositories:
      repo_configuration.set(repos.name, 'default', repos.locations[0].name)

    self.start_build(version, builder, repo_configuration)

    self.response.out.write("OK\t%s" % version)
Ejemplo n.º 2
0
  def get(self, project_key):
    
    prefs = find_or_create(ProfileProjectPreferences, dict(profile = self.profile, project = self.project))
    
    if self.effective_level > VIEWER_LEVEL:
      builders = self.fetch_active_builders()
      online_builders = [b for b in builders if b.is_online()]
      recent_builders = [b for b in builders if not b.is_online()]
    
      last_used_builder = self.profile.last_used_builder
      if last_used_builder and last_used_builder.key() not in map(lambda b: b.key(), builders):
        last_used_builder = None
        
      repo_configuration = untabularize(repo_configuration_info(), prefs.repository_choices)
      script_info = self.project.script_info()
      for repos in script_info.alternable_repositories:
        if repo_configuration.has(repos.name):
          repos.chosen_one = repo_configuration.get(repos.name).location_name
        else:
          repos.chosen_one = 'default'
      
      self.data.update(online_builders = online_builders, recent_builders = recent_builders,
        builders = online_builders + recent_builders, last_used_builder = last_used_builder)
    
    num_latest = self.config.num_latest_builds
    num_recent = self.config.num_recent_builds
    builds = self.project.builds.order('-created_at').fetch(max(num_latest, num_recent))
    for build in builds:
      build.calculate_time_deltas(self.now)
    for build in builds:
      build.check_abandoning(self.config.build_abandoned_after)
    
    latest_builds = builds[0:num_latest]
    recent_builds = builds[0:num_recent]
    for build in latest_builds:
      build.calculate_derived_data()
      build.calculate_active_message()
      
    recent_builds = filter(lambda build: build.state != BUILD_SUCCEEDED, recent_builds)

    num_successful = num_recent
    successful_builds = self.project.builds.filter('state =', BUILD_SUCCEEDED).order('-created_at').fetch(num_successful)
    for build in successful_builds:
      build.calculate_time_deltas(self.now)

    next_version = calculate_next_version(builds[0] if builds else None)
    
    self.data.update(
      latest_builds = latest_builds,
      recent_builds = recent_builds,
      successful_builds = successful_builds,
      num_latest_builds = num_latest,
      num_recent_builds = num_recent,
      num_successful = num_successful,
      next_version = next_version,
    )
    self.render_and_finish('project', 'index.html')
Ejemplo n.º 3
0
  def post(self, project_key):
    version = self.request.get('version')
    if version == None or len(version) == 0:
      logging.warning("BuildProjectHandler: version is not specified")
      self.error(500)
      return
      
    existing_count = self.project.builds.filter('version =', version).count()
    if existing_count > 0:
      logging.info("Ignoring build request with the same version number (%s, project %s)" % (version, self.project.name))
      self.redirect_and_finish('/projects/%s' % self.project.urlname(),
        flash = "Version %s already exists. Please pick another." % version)

    script_info = self.project.script_info()
    repo_configuration = repo_configuration_info()
    for repos in script_info.alternable_repositories:
      chosen_location_name = (self.request.get("location_%s" % repos.permalink) or '')
      if chosen_location_name == '':
        self.redirect_and_finish('/projects/%s' % self.project.urlname(),
          flash = "Sorry, please also choose a repository for %s." % (repos.name))
      default_location = repos.locations[0]
      if chosen_location_name == default_location.name:
        repo_configuration.set(repos.name, 'default', default_location.name)
      elif chosen_location_name in map(lambda l: l.name, repos.locations):
        repo_configuration.set(repos.name, 'manual', chosen_location_name)
      else:
        raise str("Sorry, location %s is no longer available for repository %s." % (chosen_location_name, repos.name))
        self.redirect_and_finish('/projects/%s' % self.project.urlname(),
          flash = "Sorry, location %s is no longer available for repository %s." % (chosen_location_name, repos.name))

    self.start_build(version, self.builder, repo_configuration)
    
    self.profile.last_used_builder = self.builder
    self.profile.put()
        
    update_or_insert(ProfileProjectPreferences, dict(profile = self.profile, project = self.project),
      repository_choices = tabularize(repo_configuration.without_default_choices()),
      initial_values = dict(project = self.project.key(), profile = self.profile.key()))
    
    self.redirect_and_finish('/projects/%s' % self.project.urlname(),
      flash = "Started bulding version %s. Please refresh this page to track status." % version)
Ejemplo n.º 4
0
 def repo_configuration_obj(self):
   if not hasattr(self, 'x_repo_configuration'):
     self.x_repo_configuration = untabularize(repo_configuration_info(), self.repo_configuration)
   return self.x_repo_configuration