@Override public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { EnvVars env = build.getEnvironment(listener); env.overrideAll(build.getBuildVariables()); EnvVariableResolver helper = new EnvVariableResolver(build, listener); boolean success = true; System.out.println("Loading Blueprint !"); int counter = 1; for (BlueprintParam param : params) { System.out.println("Creating package from directory : " + param.getBlueprintPath()); // Resolve any environment variables in the parameters BlueprintParam fparam = new BlueprintParam( helper.replaceBuildParamWithValue(param.getServerUrl()), helper.replaceBuildParamWithValue(param.getUserName()), helper.replaceBuildParamWithValue(param.getPassword()), helper.replaceBuildParamWithValue(param.getTenant()), param.getPackageBlueprint(), env.get("WORKSPACE") + "/" + param.getBlueprintPath(), param.getOverWrite(), param.getPublishBlueprint(), param.getServiceCategory()); final Blueprint blueprint = newBlueprint(listener.getLogger(), fparam); try { if (blueprint.Create()) { this.blueprintList.add(blueprint); } else { build.setResult(Result.FAILURE); success = false; break; } } catch (ArchiveException e) { e.printStackTrace(); } } return success; }
@Override public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException { EnvVars env = build.getEnvironment(listener); env.overrideAll(build.getBuildVariables()); EnvVariableResolver helper = new EnvVariableResolver(build, listener); boolean success = true; int counter = 1; for (PluginParam param : params) { // resolve build vars in request params List<RequestParam> rparamResolved = new ArrayList<RequestParam>(); ; for (RequestParam rparam : param.getRequestParams()) { String rparamString = helper.replaceBuildParamWithValue(rparam.getRequestParam().toString()); rparamResolved.add(new RequestParam(rparamString)); } // Resolve any environment variables in the parameters PluginParam fparam = new PluginParam( helper.replaceBuildParamWithValue(param.getServerUrl()), helper.replaceBuildParamWithValue(param.getUserName()), helper.replaceBuildParamWithValue(param.getPassword()), helper.replaceBuildParamWithValue(param.getTenant()), helper.replaceBuildParamWithValue(param.getBluePrintName()), param.isWaitExec(), param.getRequestTemplate(), rparamResolved); final Deployment deployment = newDeployment(listener.getLogger(), fparam); if (deployment.Create()) { this.deployments.add(deployment); // change counter to string and append be for build environment String strCounter = Integer.toString(counter) + "be"; env.putAll(deployment.getDeploymentComponents(strCounter)); counter++; } else { build.setResult(Result.FAILURE); success = false; break; } if (!success) { doTearDown(); return null; } } return new Environment() { @Override public boolean tearDown(AbstractBuild build, BuildListener listener) throws IOException, InterruptedException { return doTearDown(); } }; }