use of org.jboss.pnc.model.Base32LongID in project pnc by project-ncl.
the class DatastoreAdapter method initBuildRecordBuilder.
/**
* Initialize a new BuildRecord.Builder based on the data contained in the BuildTask. Note, this must be done inside
* a transaction because it fetches the BuildRecordSet entities from the database.
*
* @return The initialized build record builder
*/
private BuildRecord.Builder initBuildRecordBuilder(BuildTask buildTask) {
BuildOptions buildOptions = buildTask.getBuildOptions();
BuildRecord.Builder builder = BuildRecord.Builder.newBuilder().id(buildTask.getId()).buildConfigurationAudited(buildTask.getBuildConfigurationAudited()).user(buildTask.getUser()).submitTime(buildTask.getSubmitTime()).startTime(buildTask.getStartTime()).productMilestone(buildTask.getProductMilestone()).temporaryBuild(buildOptions.isTemporaryBuild()).alignmentPreference(buildOptions.getAlignmentPreference()).noRebuildCause(buildTask.getNoRebuildCause());
if (buildTask.getEndTime() == null) {
buildTask.setEndTime(Date.from(Instant.now()));
}
builder.endTime(buildTask.getEndTime());
if (buildTask.getBuildConfigSetRecordId() != null) {
BuildConfigSetRecord buildConfigSetRecord = datastore.getBuildConfigSetRecordById(buildTask.getBuildConfigSetRecordId());
builder.buildConfigSetRecord(buildConfigSetRecord);
}
List<Base32LongID> dependencies = buildTask.getDependencies().stream().map(BuildTask::getId).map(Base32LongID::new).collect(Collectors.toList());
builder.dependencyBuildRecordIds(dependencies.toArray(new Base32LongID[dependencies.size()]));
List<Base32LongID> dependants = buildTask.getDependants().stream().map(BuildTask::getId).map(Base32LongID::new).collect(Collectors.toList());
builder.dependentBuildRecordIds(dependants.toArray(new Base32LongID[dependants.size()]));
return builder;
}
use of org.jboss.pnc.model.Base32LongID in project pnc by project-ncl.
the class BuildResultPushManagerTest method buildRecord.
private BuildRecord buildRecord(boolean withExecutionRootName) {
BuildRecord record = new BuildRecord();
record.setId(new Base32LongID(Sequence.nextId()));
record.setStatus(BuildStatus.SUCCESS);
record.setBuildConfigurationAudited(bca);
record.setDependencies(Collections.emptySet());
record.setStartTime(new Date());
record.setEndTime(new Date());
record.setScmRepoURL("https://example.com/foo.git");
record.setScmRevision("abcdef012345");
if (withExecutionRootName) {
record.setExecutionRootName("execution:root");
}
buildRecordRepository.save(record);
return record;
}
use of org.jboss.pnc.model.Base32LongID in project pnc by project-ncl.
the class BuildProviderImpl method getBuiltArtifactIds.
@Override
public Set<String> getBuiltArtifactIds(String buildId) {
final Base32LongID id = parseId(buildId);
BuildRecord buildRecord = repository.queryById(id);
return nullableStreamOf(buildRecord.getBuiltArtifacts()).map(builtArtifact -> builtArtifact.getId().toString()).collect(Collectors.toSet());
}
use of org.jboss.pnc.model.Base32LongID in project pnc by project-ncl.
the class DeliverableAnalyzerManagerImpl method analyzeDeliverables.
@Override
public DeliverableAnalyzerOperation analyzeDeliverables(String id, List<String> sourcesLink) {
int i = 1;
Map<String, String> inputParams = new HashMap<>();
for (String url : sourcesLink) {
inputParams.put(URL_PARAMETER_PREFIX + (i++), url);
}
Base32LongID operationId = operationsManager.newDeliverableAnalyzerOperation(id, inputParams).getId();
try {
startAnalysis(id, sourcesLink, operationId);
return deliverableAnalyzerOperationMapper.toDTO((org.jboss.pnc.model.DeliverableAnalyzerOperation) operationsManager.updateProgress(operationId, ProgressStatus.IN_PROGRESS));
} catch (RuntimeException ex) {
operationsManager.setResult(operationId, OperationResult.SYSTEM_ERROR);
throw ex;
}
}
use of org.jboss.pnc.model.Base32LongID in project pnc by project-ncl.
the class BrewPusherImpl method pushBuild.
@Override
public BuildPushResult pushBuild(String buildId, BuildPushParameters buildPushParameters) throws ProcessException {
Base32LongID id = BuildMapper.idMapper.toEntity(buildId);
BuildRecord build = buildRecordRepository.queryById(BuildMapper.idMapper.toEntity(buildId));
if (build.getStatus().equals(BuildStatus.NO_REBUILD_REQUIRED)) {
throw new OperationNotAllowedException("Build has NO_REBUILD_REQUIRED status, push last successful build or use force-rebuild.");
}
Long buildPushResultId = Sequence.nextId();
MDCUtils.addProcessContext(buildPushResultId.toString());
MDCUtils.addCustomContext(BUILD_ID_KEY, id.getId());
try {
return doPushBuild(id, buildPushParameters, buildPushResultId);
} finally {
MDCUtils.removeProcessContext();
MDCUtils.removeCustomContext(BUILD_ID_KEY);
}
}
Aggregations