@Override public boolean isValid() { return structureService.findBranchByName(branch.getProject().getName(), branch.getName()).isPresent(); }
protected BuildView getBuildView(ID id) { return structureService.getBuildView(structureService.getBuild(id), true); }
@Override public Collection<PromotionLevel> getTargetItems() { return structureService.getPromotionLevelListForBranch(targetBranch.getId()); }
/** * Gets the list of all branches, for all projects, which are properly configured for SVN. */ protected Stream<Branch> getSVNConfiguredBranches() { return structureService.getProjectList() .stream() // ...which have a SVN configuration .filter(project -> propertyService.hasProperty(project, SVNProjectConfigurationPropertyType.class)) // ...gets all their branches .flatMap(project -> structureService.getBranchesForProject(project.getId()).stream()) // ...which have a SVN configuration .filter(branch -> propertyService.hasProperty(branch, SVNBranchConfigurationPropertyType.class)); } }
private DataFetcher branchValidationStampsFetcher() { return environment -> { Object source = environment.getSource(); Optional<String> name = GraphqlUtils.getStringArgument(environment, "name"); if (source instanceof Branch) { Branch branch = (Branch) source; if (name.isPresent()) { return structureService.findValidationStampByName( branch.getProject().getName(), branch.getName(), name.get() ) .map(Collections::singletonList) .orElse(Collections.emptyList()); } else { return structureService.getValidationStampListForBranch(branch.getId()); } } else { return Collections.emptyList(); } }; }
checkArgList(environment, "id"); return Collections.singletonList( structureService.getBuild(ID.of(id)) ); Branch branch = structureService.findBranchByName(oProject.get(), oBranch.get()) .orElseThrow(() -> new BranchNotFoundException(oProject.get(), oBranch.get())); Project project = structureService.findProjectByName(oProject.get()) .orElseThrow(() -> new ProjectNotFoundException(oProject.get())); return structureService.buildSearch(project.getId(), form);
Collection<BranchStatusView> branchStatusViews = new ArrayList<>(); for (Project project : structureService.getProjectList()) { for (Branch branch : structureService.getBranchesForProject(project.getId())) { BuildView buildView = structureService.getBuildView(build, true); structureService.getEarliestPromotionsAfterBuild(build) );
protected void syncBuild(Branch branch, String artifactoryBuildName, String buildName, ArtifactoryClient client, JobRunListener listener) { Optional<Build> buildOpt = structureService.findBuildByName( branch.getProject().getName(), branch.getName(), String statusName = artifactoryStatus.getName(); Optional<PromotionLevel> promotionLevelOpt = structureService.findPromotionLevelByName( branch.getProject().getName(), branch.getName(), if (promotionLevelOpt.isPresent()) { Optional<PromotionRun> runOpt = structureService.getLastPromotionRunForBuildAndPromotionLevel(buildOpt.get(), promotionLevelOpt.get()); if (!runOpt.isPresent()) { statusName); structureService.newPromotionRun( PromotionRun.of( buildOpt.get(),
/** * Download a path for a branch * * @param branchId ID to download a document from */ @RequestMapping(value = "download/{branchId}") public ResponseEntity<String> download(@PathVariable ID branchId, String path) { return svnService.download(structureService.getBranch(branchId), path) .map(ResponseEntity::ok) .orElseThrow( () -> new SCMDocumentNotFoundException(path) ); }
.map(id -> structureService.getBranch(id.getBranchId()).getName()) .collect(Collectors.toList()); results.addResult( applyMissingPolicy( structureService.findBranchByName(templateBranch.getProject().getName(), missingBranchName).get(), templateDefinition.getAbsencePolicy()
private void onNewValidationRun(Event event) { // Passed validation? ValidationRun validationRun = event.getEntity(ProjectEntityType.VALIDATION_RUN); if (Objects.equals( validationRun.getLastStatus().getStatusID(), ValidationRunStatusID.STATUS_PASSED)) { // Branch Branch branch = event.getEntity(ProjectEntityType.BRANCH); // Build Build build = event.getEntity(ProjectEntityType.BUILD); // Gets all promotion levels for this branch List<PromotionLevel> promotionLevels = structureService.getPromotionLevelListForBranch(branch.getId()); // Gets all validation stamps for this branch List<ValidationStamp> validationStamps = structureService.getValidationStampListForBranch(branch.getId()); // Gets the promotion levels which have an auto promotion property promotionLevels.forEach(promotionLevel -> checkPromotionLevel(build, promotionLevel, validationStamps)); } }
@Override public Project cloneProject(Project sourceProject, ProjectCloneRequest request) { // Replacement function Function<String, String> replacementFn = replacementFn(request.getReplacements()); // Description of the target project String targetProjectDescription = replacementFn.apply(sourceProject.getDescription()); // Creates the project Project targetProject = structureService.newProject( Project.of( NameDescription.nd(request.getName(), targetProjectDescription) ) ); // Copies the properties for the project doCopyProperties(sourceProject, targetProject, replacementFn, SyncPolicy.COPY); // Creates a copy of the branch Branch sourceBranch = structureService.getBranch(request.getSourceBranchId()); String targetBranchName = replacementFn.apply(sourceBranch.getName()); String targetBranchDescription = replacementFn.apply(sourceBranch.getDescription()); Branch targetBranch = structureService.newBranch( Branch.of( targetProject, NameDescription.nd(targetBranchName, targetBranchDescription) ) ); // Configuration of the new branch doCopy(sourceBranch, targetBranch, replacementFn, SyncPolicy.COPY); // OK return targetProject; }
@Override public Collection<ValidationStamp> getSourceItems() { return structureService.getValidationStampListForBranch(sourceBranch.getId()); }
AutoPromotionProperty property = oProperty.get(); List<PromotionRun> runs = structureService.getPromotionRunsForBuildAndPromotionLevel(build, promotionLevel); if (runs.isEmpty()) { structureService.newPromotionRun( PromotionRun.of( build,
@Override public Optional<ValidationStamp> getOrCreateValidationStamp(AutoValidationStampProperty value, Branch branch, String validationStampName) { if (value.isAutoCreate()) { Optional<PredefinedValidationStamp> oPredefinedValidationStamp = predefinedValidationStampService.findPredefinedValidationStampByName(validationStampName); if (oPredefinedValidationStamp.isPresent()) { // Creates the validation stamp return Optional.of( securityService.asAdmin(() -> structureService.newValidationStampFromPredefined( branch, oPredefinedValidationStamp.get() ) ) ); } else if (value.isAutoCreateIfNotPredefined()) { // Creates a validation stamp even without a predefined one return Optional.of( securityService.asAdmin(() -> structureService.newValidationStamp( ValidationStamp.of( branch, NameDescription.nd(validationStampName, "Validation automatically created on demand.") ) ) ) ); } } return Optional.empty(); }
@Override public void createTargetItem(ValidationStamp sourceValidationStamp) { ValidationStamp targetValidationStamp = structureService.newValidationStamp( ValidationStamp.of( targetBranch, NameDescription.nd( sourceValidationStamp.getName(), replacementFn.apply(sourceValidationStamp.getDescription()) ) ) ); copyValidationStampContent(sourceValidationStamp, targetValidationStamp); }
@Override public Branch update(Branch branch, BranchBulkUpdateRequest request) { // Replacement function Function<String, String> replacementFn = replacementFn(request.getReplacements()); // Description update Branch updatedBranch = branch.withDescription( replacementFn.apply(branch.getDescription()) ); structureService.saveBranch(updatedBranch); // Updating doCopy(branch, updatedBranch, replacementFn, new SyncPolicy( SyncPolicy.TargetPresentPolicy.REPLACE, SyncPolicy.UnknownTargetPolicy.IGNORE )); // Reloads the branch return structureService.getBranch(branch.getId()); }
private Optional<Build> createBuild(String tagsPath, SVNSyncProperty syncProperty, Branch branch, TCopyEvent copy, ConfiguredBuildSvnRevisionLink<?> revisionLink, SVNRepository repository) { // Extracts the build name from the copyTo path return getBuildNameFromPath(tagsPath, revisionLink, copy.copyToLocation()) .flatMap(buildName -> { // Gets an existing build if any Optional<Build> build = structureService.findBuildByName(branch.getProject().getName(), branch.getName(), buildName); // If none exists, just creates it if (!build.isPresent()) { logger.debug("[svn-sync] Build {} does not exist - creating.", buildName); return Optional.of(doCreateBuild(branch, copy, buildName, repository)); } // If Ok to override, deletes it and creates it else if (syncProperty.isOverride()) { logger.debug("[svn-sync] Build {} already exists - overriding.", buildName); // Deletes the build structureService.deleteBuild(build.get().getId()); // Creates the build return Optional.of(doCreateBuild(branch, copy, buildName, repository)); } // Else, just puts some log entry else { logger.debug("[svn-sync] Build {} already exists - not overriding.", buildName); return Optional.empty(); } }); }
protected PromotionRun doPromote(Build build, PromotionLevel promotionLevel, String description) throws Exception { return asUser().with(build.projectId(), PromotionRunCreate.class).call(() -> structureService.newPromotionRun( PromotionRun.of( build, promotionLevel, Signature.of("test"), description ) ) ); }
@Override public Branch setTemplateDefinition(ID branchId, TemplateDefinition templateDefinition) { Branch branch = structureService.getBranch(branchId); int buildCount = structureService.getBuildCount(branch); if (buildCount > 0) { throw new BranchTemplateHasBuildException(branch.getName()); return structureService.getBranch(branchId);