Exemplo n.º 1
0
 private void validateJobNameUniqueness(ErrorCollection errors, String location) {
   if (this.jobs == null) return;
   HashSet<String> keys = new HashSet<>();
   for (CRJob var : jobs) {
     String error = var.validateNameUniqueness(keys);
     if (error != null) errors.addError(location, error);
   }
 }
Exemplo n.º 2
0
 @Override
 public void getErrors(ErrorCollection errors, String parentLocation) {
   String location = this.getLocation(parentLocation);
   errors.checkMissing(location, "name", name);
   validateAtLeastOneJob(errors, location);
   validateEnvironmentVariableUniqueness(errors, location);
   validateJobNameUniqueness(errors, location);
   if (approval != null) approval.getErrors(errors, location);
   if (jobs != null) {
     for (CRJob job : jobs) {
       job.getErrors(errors, location);
     }
   }
 }
Exemplo n.º 3
0
  public JobConfig toJobConfig(CRJob crJob) {
    JobConfig jobConfig = new JobConfig(crJob.getName());
    if (crJob.getEnvironmentVariables() != null)
      for (CREnvironmentVariable crEnvironmentVariable : crJob.getEnvironmentVariables()) {
        jobConfig.getVariables().add(toEnvironmentVariableConfig(crEnvironmentVariable));
      }

    List<CRTask> crTasks = crJob.getTasks();
    Tasks tasks = jobConfig.getTasks();
    if (crTasks != null)
      for (CRTask crTask : crTasks) {
        tasks.add(toAbstractTask(crTask));
      }

    Tabs tabs = jobConfig.getTabs();
    if (crJob.getTabs() != null)
      for (CRTab crTab : crJob.getTabs()) {
        tabs.add(toTab(crTab));
      }

    Resources resources = jobConfig.resources();
    if (crJob.getResources() != null)
      for (String crResource : crJob.getResources()) {
        resources.add(new Resource(crResource));
      }

    ArtifactPlans artifactPlans = jobConfig.artifactPlans();
    if (crJob.getArtifacts() != null)
      for (CRArtifact crArtifact : crJob.getArtifacts()) {
        artifactPlans.add(toArtifactPlan(crArtifact));
      }

    ArtifactPropertiesGenerators artifactPropertiesGenerators = jobConfig.getProperties();
    if (crJob.getArtifactPropertiesGenerators() != null)
      for (CRPropertyGenerator crPropertyGenerator : crJob.getArtifactPropertiesGenerators()) {
        artifactPropertiesGenerators.add(
            new ArtifactPropertiesGenerator(
                crPropertyGenerator.getName(),
                crPropertyGenerator.getSrc(),
                crPropertyGenerator.getXpath()));
      }

    if (crJob.isRunOnAllAgents()) jobConfig.setRunOnAllAgents(true);
    else {
      Integer count = crJob.getRunInstanceCount();
      if (count != null) jobConfig.setRunInstanceCount(count);
      // else null - meaning simple job
    }

    if (crJob.getTimeout() != null) jobConfig.setTimeout(Integer.toString(crJob.getTimeout()));
    // else null - means default server-wide timeout

    return jobConfig;
  }