public Integer call(MavenBuild build) throws IOException, InterruptedException { SurefireReport sr = build.getAction(SurefireReport.class); if(sr==null) build.getActions().add(new SurefireReport(build, result, listener)); else sr.setResult(result,listener); if(result.getFailCount()>0) build.setResult(Result.UNSTABLE); build.registerAsProjectAction(new FactoryImpl()); return result.getFailCount(); } });
public String getDisplayName() { return mavenBuild.getProject().getDisplayName(); }
public Boolean call(MavenBuild build) throws IOException { try { CoberturaBuildAction cba = build.getAction(CoberturaBuildAction.class); if (cba == null) { File cvgxml = new File(build.getRootDir(), "coverage.xml"); CoverageResult result = CoberturaCoverageParser.parse(cvgxml, null, new HashSet<String>()); result.setOwner(build); CoberturaBuildAction o = CoberturaBuildAction.load(result, null, null, false, false, false, false, false, false, 0); build.addAction(o); } else { return false; } } catch (NullPointerException e) { return false; } return true; } }
public void setResult(Result result) { if (!isBuilding()) { LOGGER.log(Level.WARNING, "JENKINS-25406: illegal attempt to change result from {0} to {1} after {2} finished building", new Object[] {getResult(), result, MavenBuild.this}); return; } MavenBuild.this.setResult(result); }
public Void call(MavenBuild build) throws IOException, InterruptedException { // if a build forks lifecycles, this method can be called multiple times List<MavenArtifactRecord> old = build.getActions(MavenArtifactRecord.class); if (!old.isEmpty()) build.getActions().removeAll(old); MavenArtifactRecord mar = new MavenArtifactRecord(build, pomArtifact, mainArtifact, attachedArtifacts, repositoryUrl, repositoryId); build.addAction(mar); return null; } }
private ViolationsBuildAction getCreateBuildAction(MavenBuild build) { ViolationsBuildAction ret = build.getAction(ViolationsBuildAction.class); if (ret == null) { ret = new ViolationsBuildAction(build); build.getActions().add(ret); } return ret; }
/** {@inheritDoc} */ @edu.umd.cs.findbugs.annotations.SuppressWarnings("BC") @Override protected BuildResult persistResult(final ParserResult project, final MavenBuild build) { TasksResult result = new TasksResult(build, getDefaultEncoding(), (TasksParserResult)project, high, normal, low); build.getActions().add(new MavenTasksResultAction(build, this, getDefaultEncoding(), high, normal, low, result)); build.registerAsProjectAction(TasksReporter.this); return result; }
public SurefireReport getChildReport(Child child) { MavenBuild b = resolveChild(child); if(b==null) return null; return b.getAction(SurefireReport.class); }
/** * Called whenever a new module build is completed, to update the aggregated * report. When multiple builds complete simultaneously, Hudson serializes * the execution of this method, so this method needs not be * concurrency-safe. * * @param moduleBuilds * Same as <tt>MavenModuleSet.getModuleBuilds()</tt> but provided * for convenience and efficiency. * @param newBuild * Newly completed build. */ public void update(final Map<MavenModule, List<MavenBuild>> moduleBuilds, final MavenBuild newBuild) { MavenResultAction<T> additionalAction = newBuild.getAction(getIndividualActionType()); MavenModule project = newBuild.getProject(); if (additionalAction != null && !getModules().contains(project)) { T existingResult = delegate.getResult(); T additionalResult = additionalAction.getResult(); if (newBuild.getResult().isBetterThan(Result.FAILURE) || additionalResult.getPluginResult().isWorseOrEqualTo(Result.FAILURE)) { getModules().add(project); setResult(createAggregatedResult(existingResult, additionalResult)); copySourceFilesToModuleBuildFolder(newBuild); } } }
for (AggregatableAction aa : newBuild.getActions(AggregatableAction.class)) { if(individuals.add(aa.getClass())) { String moduleFsName = newBuild.getProject().getModuleName().toFileSystemName(); Util.createSymlink(getRootDir(), "../../modules/"+ moduleFsName +"/builds/"+newBuild.getId() /*ugly!*/, moduleFsName, StreamTaskListener.NULL); } catch (IOException e) {
@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; }
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)); ViolationsReport report = build.getWorkspace().act( new ViolationsCollector(true, targetPath, htmlPath, config)); report.setConfig(config); report.setBuild(build); report.setBuildResult(); ViolationsBuildAction buildAction = getCreateBuildAction(build); buildAction.setReport(report); return true; }
protected Result doRun(BuildListener listener) throws Exception { reporters = getProject().createReporters(); MavenModuleSet mms = getProject().getParent(); if(debug) listener.getLogger().println("Reporters="+reporters); EnvVars envVars = getEnvironment(listener); // buildEnvironments should be set up first MavenInstallation mvn = getProject().getParent().getMaven(); MavenInformation mavenInformation = getModuleRoot().act( new MavenVersionCallable( mvn.getHome() )); new Maven3ProcessFactory( getParent().getParent(), launcher, envVars, null ) ); new MavenProcessFactory( getParent().getParent(), launcher, envVars, null ) ); margs.add("-Dmaven.repo.local="+getWorkspace().child(".repository").getRemote()); margs.add("-f",getModuleRoot().child("pom.xml").getRemote()); margs.addTokenized(getProject().getGoals()); systemProps.put("hudson.build.number",String.valueOf(getNumber()));
/** * Finds {@link Action}s from all the module builds that belong to this * {@link MavenModuleSetBuild}. One action per one {@link MavenModule}, * and newer ones take precedence over older ones. */ public <T extends Action> List<T> findModuleBuildActions(Class<T> action) { Collection<MavenModule> mods = getParent().getModules(); List<T> r = new ArrayList<T>(mods.size()); // identify the build number range. [start,end) MavenModuleSetBuild nb = getNextBuild(); int end = nb!=null ? nb.getNumber()-1 : Integer.MAX_VALUE; for (MavenModule m : mods) { MavenBuild b = m.getNearestOldBuild(end); while(b!=null && b.getNumber()>=number) { T a = b.getAction(action); if(a!=null) { r.add(a); break; } b = b.getPreviousBuild(); } } return r; }
public void registerAsProjectAction(MavenReporter reporter) { MavenBuild.this.registerAsProjectAction(reporter); }
MavenBuild mb = m.newBuild(); mb.setBuiltOnStr( getBuiltOnStr() ); ModuleName moduleName = m.getModuleName(); LOGGER.log(Level.FINER, "adding {0} to changedModules for {1} because it has changes", new Object[] {moduleName, MavenModuleSetBuild.this}); changedModules.add(moduleName); } else if (mb.getPreviousBuiltBuild() == null) { LOGGER.log(Level.FINER, "adding {0} to changedModules for {1} because we have never seen this module before", new Object[] {moduleName, MavenModuleSetBuild.this}); changedModules.add(moduleName); } else if (mb.getPreviousBuiltBuild().getResult().isWorseThan(Result.SUCCESS)) { LOGGER.log(Level.FINER, "adding {0} to changedModules for {1} because the previous build failed or was unstable", new Object[] {moduleName, MavenModuleSetBuild.this}); changedModules.add(moduleName); mb.setWorkspace(getModuleRoot().child(m.getRelativePath())); proxies.put(moduleName, mb.new ProxyImpl2(MavenModuleSetBuild.this,slistener));
public void deploy(MavenEmbedder embedder, ArtifactRepository deploymentRepository, TaskListener listener) throws MavenEmbedderException, IOException, ComponentLookupException, ArtifactDeploymentException { if(debug) listener.getLogger().println("Redeploying artifacts of "+parent+" timestamp="+parent.getTimestamp()); for (MavenBuild build : parent.getModuleLastBuilds().values()) { MavenArtifactRecord mar = build.getAction(MavenArtifactRecord.class); if(mar!=null) { if(debug) listener.getLogger().println("Deploying module: "+build+" timestamp="+build.getTimestamp()); mar.deploy(embedder,deploymentRepository,listener); } } } }
public FilePath getRootDir() { return new FilePath(MavenBuild.this.getRootDir()); }
private String registerResults(final ParserResult result, final MavenBuild mavenBuild) { T buildResult = createResult(mavenBuild, result); StringPluginLogger pluginLogger = new StringPluginLogger(pluginName); if (new NullHealthDescriptor(this).isThresholdEnabled()) { String baseUrl = getDescriptor().getPluginResultUrlName(); buildResult.evaluateStatus(thresholds, useDeltaValues, canComputeNew(), pluginLogger, baseUrl); } mavenBuild.addAction(createMavenAggregatedReport(mavenBuild, buildResult)); mavenBuild.registerAsProjectAction(HealthAwareReporter.this); Run<?, ?> referenceBuild = buildResult.getHistory().getReferenceBuild(); if (referenceBuild != null) { pluginLogger.log("Computing warning deltas based on reference build " + referenceBuild.getDisplayName()); } return pluginLogger.toString(); }
@Override public void run() { execute(new MavenBuildExecution()); getProject().updateTransientActions(); MavenModuleSetBuild parentBuild = getModuleSetBuild(); if(parentBuild!=null) parentBuild.notifyModuleBuild(this); }