예제 #1
0
 private ShellCommands getRunCommands() {
   BuildConfiguration buildConfiguration =
       new BuildConfiguration(
           "groupon/DotCi",
           ImmutableMap.of("run", of("unit", "command", "integration", "integration")),
           "buildId",
           new ShellCommands(),
           "abc123",
           8);
   return buildConfiguration.getCommands(Combination.fromString("script=unit"));
 }
예제 #2
0
 @Test
 public void should_parallelize_on_run() {
   BuildConfiguration buildConfiguration =
       new BuildConfiguration(
           "groupon/DotCi",
           ImmutableMap.of("run", of("unit", "command", "integration", "integration")),
           "buildId",
           new ShellCommands(),
           "abc123",
           8);
   Iterable<Combination> axisList = buildConfiguration.getAxisList().list();
   Assert.assertEquals(2, Iterables.size(axisList));
   Assert.assertEquals("script=unit", Iterables.get(axisList, 0).toString());
   Assert.assertEquals("script=integration", Iterables.get(axisList, 1).toString());
 }
예제 #3
0
 @Override
 public Result runBuild(DynamicBuild build, BuildExecutionContext buildExecutionContext, Launcher launcher, BuildListener listener) throws IOException, InterruptedException {
     Map<String,Object> buildEnvironment = build.getEnvironmentWithChangeSet(listener);
     ShellCommands checkoutCommands = getCheckoutCommands(buildEnvironment);
     Map config = new GroovyYamlTemplateProcessor(getDotCiYml(build), buildEnvironment).getConfig();
     this.buildConfiguration = getBuildConfiguration(build.getParent().getFullName(),config,build.getBuildId(),checkoutCommands,build.getSha(),build.getNumber());
     build.setAxisList(buildConfiguration.getAxisList());
     Result result ;
     if(buildConfiguration.isParallelized()){
         ShellScriptRunner shellScriptRunner = new ShellScriptRunner(buildExecutionContext, listener);
         Result checkoutResult = shellScriptRunner.runScript(checkoutCommands);
         if(Result.FAILURE.equals(checkoutResult)) return checkoutResult;
         result = runMultiConfigbuildRunner(build, buildConfiguration, listener,launcher);
     }else{
         result = runSubBuild(new Combination(ImmutableMap.of("script", buildConfiguration.getOnlyRun())), buildExecutionContext, listener);
     }
     Result pluginResult = runPlugins(build, buildConfiguration.getPlugins(), listener, launcher);
     Result notifierResult = runNotifiers(build, buildConfiguration.getNotifiers(), listener);
     return  result.combine(pluginResult).combine(notifierResult);
 }
예제 #4
0
    private Result runMultiConfigbuildRunner(final DynamicBuild dynamicBuild, final BuildConfiguration buildConfiguration, final BuildListener listener, Launcher launcher) throws IOException, InterruptedException {
        SubBuildScheduler subBuildScheduler = new SubBuildScheduler(dynamicBuild, this, new SubBuildScheduler.SubBuildFinishListener() {
            @Override
            public void runFinished(DynamicSubBuild subBuild) throws IOException {
                for (DotCiPluginAdapter plugin : buildConfiguration.getPlugins()) {
                    plugin.runFinished(subBuild, dynamicBuild, listener);
                }
            }
        });

        try {
            Iterable<Combination> axisList = buildConfiguration.getAxisList().list();
            Result combinedResult = subBuildScheduler.runSubBuilds(axisList, listener);
            dynamicBuild.setResult(combinedResult);
            return combinedResult;
        } finally {
            try {
                subBuildScheduler.cancelSubBuilds(listener.getLogger());
            } catch (Exception e) {
                // There is nothing much we can do at this point
            }
        }
    }
예제 #5
0
 @Override
 public Result runSubBuild(Combination combination, BuildExecutionContext buildExecutionContext, BuildListener listener) throws IOException, InterruptedException {
     ShellScriptRunner shellScriptRunner = new ShellScriptRunner(buildExecutionContext, listener);
     return shellScriptRunner.runScript(buildConfiguration.getCommands(combination));
 }