private Void retrieveRepositoryManagerResults(BuildExecutionSession buildExecutionSession) { try { buildExecutionSession.setStatus( BuildExecutionStatus.COLLECTING_RESULTS_FROM_REPOSITORY_NAMAGER); RunningEnvironment runningEnvironment = buildExecutionSession.getRunningEnvironment(); buildExecutionSession.setRunningEnvironment(runningEnvironment); RepositorySession repositorySession = runningEnvironment.getRepositorySession(); RepositoryManagerResult repositoryManagerResult = repositorySession.extractBuildArtifacts(); buildExecutionSession.setRepositoryManagerResult(repositoryManagerResult); } catch (Throwable e) { throw new BuildProcessException(e, buildExecutionSession.getRunningEnvironment()); } return null; }
@Test public void extractBuildArtifactsTriggersBuildRepoPromotionToChainGroup() throws Exception { String path = "/org/myproj/myproj/1.0/myproj-1.0.pom"; String content = "This is a test " + System.currentTimeMillis(); String buildId = "build"; // create a dummy build execution, and a repo session based on it BuildExecution execution = new TestBuildExecution(buildId); RepositorySession session = driver.createBuildRepository(execution, accessToken); // simulate a build deploying a file. driver .getIndy(accessToken) .module(IndyFoloContentClientModule.class) .store( buildId, StoreType.hosted, buildId, path, new ByteArrayInputStream(content.getBytes())); // now, extract the build artifacts. This will trigger promotion of the build hosted repo to the // untested-builds group. RepositoryManagerResult result = session.extractBuildArtifacts(); // do some sanity checks while we're here List<Artifact> deps = result.getBuiltArtifacts(); assertThat(deps.size(), equalTo(1)); Artifact a = deps.get(0); assertThat(a.getFilename(), equalTo(new File(path).getName())); // end result: the untested-builds group should contain the build hosted repo. Group untestedBuildsGroup = driver .getIndy(accessToken) .stores() .load(StoreType.group, UNTESTED_BUILDS_GROUP, Group.class); assertThat( untestedBuildsGroup.getConstituents().contains(new StoreKey(StoreType.hosted, buildId)), equalTo(true)); }