@Override public boolean perform( AbstractBuild<?, ?> build, Launcher launcher, final BuildListener listener) { if (build.getResult().isWorseOrEqualTo(Result.FAILURE)) return false; listener.getLogger().println(Messages.TestflightRecorder_InfoUploading()); try { EnvVars vars = build.getEnvironment(listener); String workspace = vars.expand("$WORKSPACE"); List<TestflightUploader.UploadRequest> urList = new ArrayList<TestflightUploader.UploadRequest>(); for (TestflightTeam team : createDefaultPlusAdditionalTeams()) { try { TestflightUploader.UploadRequest ur = createPartialUploadRequest(team, vars, build); urList.add(ur); } catch (MisconfiguredJobException mje) { listener.getLogger().println(mje.getConfigurationMessage()); return false; } } for (TestflightUploader.UploadRequest ur : urList) { TestflightRemoteRecorder remoteRecorder = new TestflightRemoteRecorder(workspace, ur, listener); final List<Map> parsedMaps; try { Object result = launcher.getChannel().call(remoteRecorder); parsedMaps = (List<Map>) result; } catch (UploadException ue) { listener .getLogger() .println(Messages.TestflightRecorder_IncorrectResponseCode(ue.getStatusCode())); listener.getLogger().println(ue.getResponseBody()); return false; } if (parsedMaps.size() == 0) { listener.getLogger().println(Messages.TestflightRecorder_NoUploadedFile(ur.filePaths)); return false; } for (Map parsedMap : parsedMaps) { addTestflightLinks(build, listener, parsedMap); } } } catch (Throwable e) { listener.getLogger().println(e); e.printStackTrace(listener.getLogger()); return false; } return true; }
/** * Writes the configuration file required to opt out of SDK usage statistics gathering. * * @param launcher Used for running tasks on the remote node. * @param listener Used to access logger. */ public static void optOutOfSdkStatistics( Launcher launcher, BuildListener listener, String androidSdkHome) { Callable<Void, Exception> optOutTask = new StatsOptOutTask(androidSdkHome, listener); try { launcher.getChannel().call(optOutTask); } catch (Exception e) { log(listener.getLogger(), "SDK statistics opt-out failed.", e); } }
@Override public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { PrintStream logger = listener.getLogger(); EnvVariableResolver resolver = new EnvVariableResolver(build, listener); // Resolve the workflowName to workflowId BuildParam buildParam = new BuildParam(serverUrl, userName, password, tenant, null); OrchestratorClient client = new OrchestratorClient(buildParam); String workflowId = null; try { String resolvedWfName = resolver.getValueForBuildParameter(workflowName); List<Workflow> workflows = client.fetchWorkflows(); for (Workflow workflow : workflows) { if (workflow.getName().equals(resolvedWfName)) { workflowId = workflow.getId(); break; } } } catch (Exception e) { throw new IOException(e.getMessage(), e); } if (workflowId == null) { throw new IOException("Workflow doesn't exist in the server."); } BuildParam param = new BuildParam( resolver.getValueForBuildParameter(serverUrl), resolver.getValueForBuildParameter(userName), resolver.getValueForBuildParameter(password), resolver.getValueForBuildParameter(tenant), workflowId, waitExec, resolver.getValueForBuildParameter(inputParams)); logger.println("Starting Orchestrator workflow execution : " + param.getWorkflowName()); param.validate(); OrchestratorCallable callable = new OrchestratorCallable(param); Map<String, String> outputParameters = launcher.getChannel().call(callable); if (outputParameters != null && outputParameters.size() > 0) { logger.println("Output Parameters from the workflow execution"); for (Map.Entry entry : outputParameters.entrySet()) { logger.println(entry.getKey() + " : " + entry.getValue()); } } OrchestratorEnvAction orchestratorAction = new OrchestratorEnvAction(outputParameters); build.addAction(orchestratorAction); return true; }
public String getSbtLaunchJar(Launcher launcher) throws IOException, InterruptedException { return launcher .getChannel() .call( new Callable<String, IOException>() { public String call() throws IOException { File sbtLaunchJarFile = getSbtLaunchJarFile(); if (sbtLaunchJarFile.exists()) return sbtLaunchJarFile.getPath(); return getHome(); } }); }
@SuppressWarnings("serial") public String getExecutable(Launcher launcher) throws IOException, InterruptedException { return launcher .getChannel() .call( new Callable<String, IOException>() { public String call() throws IOException { File exe = getExecutableFile(); if (exe.exists()) return exe.getPath(); throw new IOException(exe.getPath() + " doesn't exist"); } }); }
/** * Determines the Android platform for an existing emulator, via its metadata config file. * * @param launcher Used to access files on the remote node. * @param emuConfig The emulator whose target platform we want to determine. * @return The platform identifier. */ private static String getPlatformFromExistingEmulator( Launcher launcher, final EmulatorConfig emuConfig) throws IOException, InterruptedException { return launcher .getChannel() .call( new Callable<String, IOException>() { public String call() throws IOException { File metadataFile = emuConfig.getAvdMetadataFile(); Map<String, String> metadata = Utils.parseConfigFile(metadataFile); return metadata.get("target"); } private static final long serialVersionUID = 1L; }); }
@Override public VirtualChannel getChannel() { return inner.getChannel(); }