/** * Check that the provided file is a relative path. And check that it exists, just in case. */ public FormValidation doCheckFileRelative(@QueryParameter String value) throws IOException, ServletException { String v = fixEmpty(value); if ((v == null) || (v.length() == 0)) { // Null values are allowed. return FormValidation.ok(); } if ((v.startsWith("/")) || (v.startsWith("\\")) || (v.matches("^\\w\\:\\\\.*"))) { return FormValidation.error("Alternate settings file must be a relative path."); } MavenModuleSetBuild lb = getLastBuild(); if (lb!=null) { FilePath ws = lb.getWorkspace(); if(ws!=null) return ws.validateRelativePath(value,true,true); } return FormValidation.ok(); }
private static String getMavenVersion(MavenModuleSetBuild build, EnvVars vars, BuildListener listener) throws IOException, InterruptedException { final Maven.MavenInstallation installation = getMavenInstallation(build, vars, listener); final String home = installation.getHome(); if (build.getWorkspace() == null) { throw new IllegalStateException("build.getWorkspace() is null"); } return build.getWorkspace().act(new MasterToSlaveCallable<String, IOException>() { @Override public String call() throws IOException { try { return MavenEmbedderUtils.getMavenVersion(new File(home)).getVersion(); } catch (MavenEmbedderException e) { throw new RuntimeException(e); } } }); } }
private static boolean isAtLeast(MavenModuleSetBuild build, String mavenHome, String version) throws IOException, InterruptedException { return build.getWorkspace().act(new MavenVersionCallable(mavenHome, version)); }
@Override public boolean end(MavenBuild build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { registered = false; FilePath htmlPath = new FilePath(new File(build.getProject().getRootDir(), VIOLATIONS)); FilePath targetPath = new FilePath(new File(build.getRootDir(), VIOLATIONS)); FilePath workspace = build.getWorkspace(); if (workspace == null) { MavenModuleSetBuild parent = build.getModuleSetBuild(); throw new IOException("No workspace for " + build + "; parent workspace: " + (parent != null ? parent.getWorkspace() : "N/A") + "; builtOnStr=" + build.getBuiltOnStr() + "; builtOn=" + build.getBuiltOn()); } ViolationsReport report = workspace.act(new ViolationsCollector(true, targetPath, htmlPath, config)); report.setConfig(config); report.setBuild(build); report.setBuildResult(); ViolationsBuildAction buildAction = getCreateBuildAction(build); buildAction.setReport(report); return true; }
@Override public void buildEnvVars(Map<String, String> env) { if (build.getWorkspace() == null) { env, build, buildListener, publisherContext, resolverContext, build.getWorkspace(), launcher); propertiesFilePath = configuration.getPropertiesFile(); } catch (Exception e) {
this.workspaceProper = project.getLastBuild().getWorkspace().getRemote(); if (project.usesPrivateRepository()) { this.privateRepository = project.getLastBuild().getWorkspace().child(".repository").getRemote(); } else { this.privateRepository = null; project.getScm().getModuleRoot( project.getLastBuild().getWorkspace(), project.getLastBuild() ).getRemote();
this.workspaceProper = build.getWorkspace().getRemote(); LOGGER.fine("Workspace is " + workspaceProper); FilePath localRepo = project.getLocalRepository().locate(build); project.getScm().getModuleRoot( build.getWorkspace(), project.getLastBuild() ).getRemote();
FilePath parentLoc = getWorkspace().child(rootPOM); if(!pom.exists() && parentLoc.exists()) pom = parentLoc;
FilePath parentLoc = getWorkspace().child(rootPOM); if(!pom.exists() && parentLoc.exists()) pom = parentLoc; margs.add("-Dmaven.repo.local="+getWorkspace().child(".repository")); } else { FilePath mrSettings = getModuleRoot().child(project.getAlternateSettings()); FilePath wsSettings = getWorkspace().child(project.getAlternateSettings()); if (!wsSettings.exists() && mrSettings.exists()) wsSettings = mrSettings;