Esempio n. 1
0
 public Set<String> parseSecurityGroups() {
   if (securityGroups == null || "".equals(securityGroups.trim())) {
     return Collections.emptySet();
   } else {
     return new HashSet<String>(Arrays.asList(securityGroups.split("\\s*,\\s*")));
   }
 }
  @Override
  public Collection<? extends Action> getProjectActions(AbstractProject<?, ?> project) {
    ArrayList<TestflightBuildAction> actions = new ArrayList<TestflightBuildAction>();
    RunList<? extends AbstractBuild<?, ?>> builds = project.getBuilds();

    Collection predicated =
        CollectionUtils.select(
            builds,
            new Predicate() {
              public boolean evaluate(Object o) {
                Result result = ((AbstractBuild<?, ?>) o).getResult();
                if (result == null) return false; // currently running builds can have a null result
                return result.isBetterOrEqualTo(Result.SUCCESS);
              }
            });

    ArrayList<AbstractBuild<?, ?>> filteredList = new ArrayList<AbstractBuild<?, ?>>(predicated);

    Collections.reverse(filteredList);
    for (AbstractBuild<?, ?> build : filteredList) {
      List<TestflightBuildAction> testflightActions = build.getActions(TestflightBuildAction.class);
      if (testflightActions != null && testflightActions.size() > 0) {
        for (TestflightBuildAction action : testflightActions) {
          actions.add(new TestflightBuildAction(action));
        }
        break;
      }
    }

    return actions;
  }
 /** Compiles all the patterns from {@link #getLogPattern()} */
 private List<Pattern> createPatternsList() {
   String logPattern = getLogPattern();
   if (logPattern == null || logPattern.isEmpty()) {
     return Collections.emptyList();
   }
   List<Pattern> result = new LinkedList<Pattern>();
   Scanner scanner = new Scanner(logPattern);
   while (scanner.hasNextLine()) {
     String line = scanner.nextLine();
     Pattern pattern = Pattern.compile(line);
     result.add(pattern);
   }
   return result;
 }
Esempio n. 4
0
  public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException {
    modules = Collections.emptyMap(); // needed during load
    super.onLoad(parent, name);

    modules =
        loadChildren(
            this,
            getModulesDir(),
            new Function1<ModuleName, MavenModule>() {
              public ModuleName call(MavenModule module) {
                return module.getModuleName();
              }
            });
    // update the transient nest level field.
    MavenModule root = getRootModule();
    if (root != null && root.getChildren() != null) {
      List<MavenModule> sortedList = new ArrayList<MavenModule>();
      Stack<MavenModule> q = new Stack<MavenModule>();
      root.nestLevel = 0;
      q.push(root);
      while (!q.isEmpty()) {
        MavenModule p = q.pop();
        sortedList.add(p);
        List<MavenModule> children = p.getChildren();
        if (children != null) {
          for (MavenModule m : children) m.nestLevel = p.nestLevel + 1;
          for (int i = children.size() - 1; i >= 0; i--) // add them in the reverse order
          q.push(children.get(i));
        }
      }
      this.sortedActiveModules = sortedList;
    } else {
      this.sortedActiveModules = getDisabledModules(false);
    }

    if (reporters == null)
      reporters = new DescribableList<MavenReporter, Descriptor<MavenReporter>>(this);
    reporters.setOwner(this);
    if (publishers == null)
      publishers = new DescribableList<Publisher, Descriptor<Publisher>>(this);
    publishers.setOwner(this);
    if (buildWrappers == null)
      buildWrappers = new DescribableList<BuildWrapper, Descriptor<BuildWrapper>>(this);
    buildWrappers.setOwner(this);

    updateTransientActions();
  }
Esempio n. 5
0
  /**
   * Provisions a new EC2 slave based on the currently running instance on EC2, instead of starting
   * a new one.
   */
  public EC2AbstractSlave attach(String instanceId, TaskListener listener)
      throws AmazonClientException, IOException {
    PrintStream logger = listener.getLogger();
    AmazonEC2 ec2 = getParent().connect();

    try {
      logger.println("Attaching to " + instanceId);
      LOGGER.info("Attaching to " + instanceId);
      DescribeInstancesRequest request = new DescribeInstancesRequest();
      request.setInstanceIds(Collections.singletonList(instanceId));
      Instance inst = ec2.describeInstances(request).getReservations().get(0).getInstances().get(0);
      return newOndemandSlave(inst);
    } catch (FormException e) {
      throw new AssertionError(); // we should have discovered all
      // configuration issues upfront
    }
  }
Esempio n. 6
0
 public List<EC2Tag> getTags() {
   if (null == tags) return null;
   return Collections.unmodifiableList(tags);
 }
 private void setLastCompleted(JobInvocation job) {
   lastCompleted = Collections.singleton(job);
 }