@NotNull @Override @JsonIgnore public String getRunMetricName() { return build.getName(); }
@Override public OptionalLong getRevision(RevisionPattern data, Build build, SVNBranchConfigurationProperty branchConfigurationProperty) { return data.extractRevision(build.getName()); }
@Override public String getBuildPath(NoConfig data, Build build, SVNBranchConfigurationProperty branchConfigurationProperty) { return branchConfigurationProperty.getCuredBranchPath() + "@" + build.getName(); }
@Override public List<Decoration<Long>> getDecorations(ProjectEntity entity) { if (entity instanceof Build) { // Gets the revision for this build OptionalLong revision = svnChangeLogService.getBuildRevision((Build) entity); if (revision.isPresent()) { // If the revision == build name, no need for decoration if (StringUtils.equals( String.valueOf(revision.getAsLong()), ((Build) entity).getName() )) { return Collections.emptyList(); } else { long lRevision = revision.getAsLong(); return Collections.singletonList( Decoration.of( this, lRevision ) ); } } else { return Collections.emptyList(); } } else { throw new IllegalArgumentException("Expecting build"); } }
@Override public void validateBuild(Build build) throws BuildValidationException { propertyService.getProperty(build.getBranch(), SVNBranchConfigurationPropertyType.class).option().ifPresent(property -> { // Gets the configured link ConfiguredBuildSvnRevisionLink<Object> revisionLink = buildSvnRevisionLinkService.getConfiguredBuildSvnRevisionLink(property.getBuildRevisionLink()); // Tests the validity of the build name if (!revisionLink.isValidBuildName(build.getName())) { throw new BuildValidationException( String.format( "Build %s does not comply with the SVN configuration", build.getName() ) ); } }); } }
protected Optional<String> getTagPath(T data, Build build, SVNBranchConfigurationProperty branchConfigurationProperty) { // Gets the tag name return getTagName(data, build.getName()) .flatMap(tagName -> { // Repository for the branch SVNRepository svnRepository = svnService.getRequiredSVNRepository(build.getBranch()); // Gets the tag path return svnService.getTagPathForTagName(svnRepository, branchConfigurationProperty.getCuredBranchPath(), tagName); }); }
@Override public String getEntityDisplayName() { return String.format("Validation run %s#%d for %s/%s/%s", validationStamp.getName(), runOrder, build.getBranch().getProject().getName(), build.getBranch().getName(), build.getName() ); }
protected SearchResult toSearchResult(Build build) { return new SearchResult( build.getEntityDisplayName(), String.format("%s -> %s", build.getProject().getName(), build.getName()), uriBuilder.getEntityURI(build), uriBuilder.getEntityPage(build), 100 ); } }
@Override public String getEntityDisplayName() { return String.format("Promotion run %s/%s/%s/%s", build.getBranch().getProject().getName(), build.getBranch().getName(), build.getName(), promotionLevel.getName() ); }
@Override public String render(ProjectEntity projectEntity, Event event) { switch (projectEntity.getProjectEntityType()) { case PROJECT: return ((Project) projectEntity).getName(); case BRANCH: return ((Branch) projectEntity).getName(); case PROMOTION_LEVEL: return ((PromotionLevel) projectEntity).getName(); case VALIDATION_STAMP: return ((ValidationStamp) projectEntity).getName(); case BUILD: return ((Build) projectEntity).getName(); case VALIDATION_RUN: return "#" + ((ValidationRun) projectEntity).getRunOrder(); case PROMOTION_RUN: PromotionRun promotionRun = (PromotionRun) projectEntity; return String.format( "%s->%s", promotionRun.getBuild().getName(), promotionRun.getPromotionLevel().getName() ); default: throw new EventCannotRenderEntityException(event.getEventType().getTemplate(), projectEntity); } }
@Override public Event deleteBuild(Build build) { return Event.of(DELETE_BUILD) .withBranch(build.getBranch()) .with("build", build.getName()) .with("build_id", build.getId().toString()) .get(); }
@Override public Build saveBuild(Build build) { // Update try { getNamedParameterJdbcTemplate().update( "UPDATE BUILDS SET NAME = :name, DESCRIPTION = :description, CREATION = :creation, CREATOR = :creator WHERE ID = :id", params("name", build.getName()) .addValue("description", build.getDescription()) .addValue("creation", dateTimeForDB(build.getSignature().getTime())) .addValue("creator", build.getSignature().getUser().getName()) .addValue("id", build.id()) ); return build; } catch (DuplicateKeyException ex) { throw new BuildNameAlreadyDefinedException(build.getName()); } }
@Override public Build newBuild(Build build) { // Creation try { int id = dbCreate( "INSERT INTO BUILDS(BRANCHID, NAME, DESCRIPTION, CREATION, CREATOR) VALUES (:branchId, :name, :description, :creation, :creator)", params("name", build.getName()) .addValue("description", build.getDescription()) .addValue("branchId", build.getBranch().id()) .addValue("creation", dateTimeForDB(build.getSignature().getTime())) .addValue("creator", build.getSignature().getUser().getName()) ); return build.withId(id(id)); } catch (DuplicateKeyException ex) { throw new BuildNameAlreadyDefinedException(build.getName()); } }