public PipelineConfig pipelineConfigNamed(String pipelineName) { return goConfigService.pipelineConfigNamed(new CaseInsensitiveString(pipelineName)); }
public MaterialConfigs materialConfigsFor(final CaseInsensitiveString name) { return pipelineConfigNamed(name).materialConfigs(); }
@RequestMapping(value = "/tab/pipeline/history", method = RequestMethod.GET) public ModelAndView list(@RequestParam("pipelineName") String pipelineName) { Map model = new HashMap(); try { PipelineConfig pipelineConfig = goConfigService.pipelineConfigNamed(new CaseInsensitiveString(pipelineName)); model.put("pipelineName", pipelineConfig.name()); model.put("isEditableViaUI", goConfigService.isPipelineEditable(pipelineName)); return new ModelAndView("pipeline/pipeline_history", model); } catch (PipelineNotFoundException e) { model.put("errorMessage", e.getMessage()); return new ModelAndView("exceptions_page", model); } }
public MaterialConfig materialForPipelineWithFingerprint(String pipelineName, String fingerprint) { for (MaterialConfig materialConfig : pipelineConfigNamed(new CaseInsensitiveString(pipelineName)).materialConfigs()) { if (materialConfig.getFingerprint().equals(fingerprint)) { return materialConfig; } } throw new RuntimeException(format("Pipeline [%s] does not have a material with fingerprint [%s]", pipelineName, fingerprint)); }
public boolean isPipelineEditable(CaseInsensitiveString pipelineName) { PipelineConfig pipelineConfig; try { pipelineConfig = pipelineConfigNamed(pipelineName); } catch (PipelineNotFoundException e) { return false; } return isOriginLocal(pipelineConfig.getOrigin()); }
private void appendFollowingStagesFromConfig(String pipelineName, StageInstanceModels stageHistory) { stageHistory.updateFutureStagesFrom(goConfigService.pipelineConfigNamed(new CaseInsensitiveString(pipelineName))); }
private int limitForPipeline(String pipelineName, int limit) { return goConfigService.pipelineConfigNamed(new CaseInsensitiveString(pipelineName)).size() * limit; }
public CommentRenderer getCommentRendererFor(String pipelineName) { return pipelineConfigNamed(new CaseInsensitiveString(pipelineName)).getCommentRenderer(); }
private boolean isConfigOriginSameAsUpstream(PipelineConfig pipelineConfig, BuildCause buildCause) { if (buildCause.hasDependencyMaterials()) { for(DependencyMaterial material : buildCause.getDependencyMaterials()) { PipelineConfig upstreamConfig = goConfigService.pipelineConfigNamed(material.getPipelineName()); if (pipelineConfig.hasSameConfigOrigin(upstreamConfig)) { return true; } } } return false; }
public void autoSchedulePipeline(String pipelineName, OperationResult result, long trackingId) { schedulingPerformanceLogger.autoSchedulePipelineStart(trackingId, pipelineName); try { PipelineConfig pipelineConfig = goConfigService.pipelineConfigNamed(new CaseInsensitiveString(pipelineName)); newProduceBuildCause(pipelineConfig, new AutoBuild(goConfigService, pipelineService, pipelineName, systemEnvironment, materialChecker), result, trackingId); } finally { schedulingPerformanceLogger.autoSchedulePipelineFinish(trackingId, pipelineName); } }
public boolean canManuallyTrigger(String pipelineName, Username username) { return canManuallyTrigger(goConfigService.pipelineConfigNamed(new CaseInsensitiveString(pipelineName)), CaseInsensitiveString.str(username.getUsername()), new ServerHealthStateOperationResult()); }
private WaitForPipelineMaterialUpdate(CaseInsensitiveString pipelineName, BuildType buildType, ScheduleOptions scheduleOptions) { this.pipelineConfig = goConfigService.pipelineConfigNamed(pipelineName); this.buildType = buildType; this.scheduleOptions = scheduleOptions; pendingMaterials = new ConcurrentHashMap<>(); if (this.pipelineConfig.isConfigDefinedRemotely()) { // Then we must update config first and then continue as usual. // it is also possible that config will disappear at update RepoConfigOrigin configRepo = (RepoConfigOrigin) this.pipelineConfig.getOrigin(); MaterialConfig materialConfig = configRepo.getMaterial(); configMaterial = materialConfigConverter.toMaterial(materialConfig); pendingMaterials.putIfAbsent(materialConfig.getFingerprint(), configMaterial); } if (scheduleOptions.shouldPerformMDUBeforeScheduling()) { for (MaterialConfig materialConfig : pipelineConfig.materialConfigs()) { pendingMaterials.putIfAbsent(materialConfig.getFingerprint(), materialConfigConverter.toMaterial(materialConfig)); } } }
public String getRevisionsBasedOnDependenciesForDebug(CaseInsensitiveString pipelineName, final Integer targetIterationCount) { CruiseConfig cruiseConfig = goConfigService.getCurrentConfig(); FanInGraph fanInGraph = new FanInGraph(cruiseConfig, pipelineName, materialRepository, pipelineDao, systemEnvironment, materialConfigConverter); final String[] iterationData = {null}; fanInGraph.setFanInEventListener((iterationCount, dependencyFanInNodes) -> { if (iterationCount == targetIterationCount) { iterationData[0] = new GsonBuilder().setExclusionStrategies(getGsonExclusionStrategy()).create().toJson(dependencyFanInNodes); } }); PipelineConfig pipelineConfig = goConfigService.pipelineConfigNamed(pipelineName); Materials materials = materialConfigConverter.toMaterials(pipelineConfig.materialConfigs()); MaterialRevisions actualRevisions = new MaterialRevisions(); for (Material material : materials) { actualRevisions.addAll(materialRepository.findLatestModification(material)); } MaterialRevisions materialRevisions = fanInGraph.computeRevisions(actualRevisions, pipelineTimeline); if (iterationData[0] == null) { iterationData[0] = new GsonBuilder().setExclusionStrategies(getGsonExclusionStrategy()).create().toJson(materialRevisions); } return iterationData[0]; }
public boolean canEditPipeline(String pipelineName, Username username) { PipelineConfig pipelineConfig; try { pipelineConfig = pipelineConfigNamed(new CaseInsensitiveString(pipelineName)); } catch (PipelineNotFoundException e) { return false; } return pipelineConfig != null && pipelineConfig.isLocal() && isUserAdminOfGroup(username.getUsername(), findGroupNameByPipeline(pipelineConfig.name())); }
GoAcl readAclBy(String pipelineName, String stageName) { PipelineConfig pipelineConfig = pipelineConfigNamed(new CaseInsensitiveString(pipelineName)); StageConfig stageConfig = pipelineConfig.findBy(new CaseInsensitiveString(stageName)); AdminsConfig adminsConfig = stageConfig.getApproval().getAuthConfig(); List<CaseInsensitiveString> users = getAuthorizedUsers(adminsConfig); return new GoAcl(users); }
public MingleConfig mingleConfigForPipelineNamed(String pipelineName, Username user, HttpLocalizedOperationResult result) { if (!securityService.hasViewPermissionForPipeline(user, pipelineName)) { result.forbidden(LocalizedMessage.forbiddenToViewPipeline(pipelineName), HealthStateType.forbiddenForPipeline(pipelineName)); return null; } PipelineConfig pipelineConfig = goConfigService.pipelineConfigNamed(new CaseInsensitiveString(pipelineName)); MingleConfig mingleConfig = pipelineConfig.getMingleConfig(); return mingleConfig.equals(new MingleConfig()) ? null : mingleConfig; }
@RequestMapping(value = "/**/pipelineHistory.json", method = RequestMethod.GET) public ModelAndView list(@RequestParam("pipelineName") String pipelineName, @RequestParam(value = "perPage", required = false) Integer perPageParam, @RequestParam(value = "start", required = false) Integer startParam, @RequestParam(value = "labelFilter", required = false) String labelFilter, HttpServletResponse response, HttpServletRequest request) { PipelineConfig pipelineConfig = goConfigService.pipelineConfigNamed(new CaseInsensitiveString(pipelineName)); String username = CaseInsensitiveString.str(SessionUtils.currentUsername().getUsername()); Pagination pagination; try { pagination = Pagination.pageStartingAt(startParam, pipelineHistoryService.totalCount(pipelineName), perPageParam); } catch (Exception e) { Map<String, Object> json = new LinkedHashMap<>(); addDeveloperErrorMessage(json, e); return jsonNotAcceptable(json).respond(response); } PipelinePauseInfo pauseInfo = pipelinePauseService.pipelinePauseInfo(pipelineName); boolean hasBuildCauseInBuffer = pipelineScheduleQueue.hasBuildCause(pipelineConfig.name()); PipelineInstanceModels pipelineHistory = StringUtils.isBlank(labelFilter) ? pipelineHistoryService.load(pipelineName, pagination, username, true) : pipelineHistoryService.findMatchingPipelineInstances(pipelineName, labelFilter, perPageParam, SessionUtils.currentUsername(), new HttpLocalizedOperationResult()); boolean hasForcedBuildCause = pipelineScheduleQueue.hasForcedBuildCause(pipelineConfig.name()); PipelineHistoryJsonPresentationModel historyJsonPresenter = new PipelineHistoryJsonPresentationModel( pauseInfo, pipelineHistory, pipelineConfig, pagination, canForce(pipelineConfig, username), hasForcedBuildCause, hasBuildCauseInBuffer, canPause(pipelineConfig, username)); return jsonFound(historyJsonPresenter.toJson()).respond(response); }
public PipelineInstanceModels load(String pipelineName, Pagination pagination, String username, boolean populateCanRun) { PipelineInstanceModels history = pipelineDao.loadHistory(pipelineName, pagination.getPageSize(), pagination.getOffset()); PipelineConfig pipelineConfig = goConfigService.pipelineConfigNamed(new CaseInsensitiveString(pipelineName)); for (PipelineInstanceModel pipelineInstanceModel : history) { populatePipelineInstanceModel(new Username(new CaseInsensitiveString(username)), populateCanRun, pipelineConfig, pipelineInstanceModel); } addEmptyPipelineInstanceIfNeeded(pipelineName, history, new Username(new CaseInsensitiveString(username)), pipelineConfig, populateCanRun); return history; }
Pipeline schedulePipeline(final CaseInsensitiveString pipelineName, final BuildCause buildCause) { try { PipelineConfig pipelineConfig = goConfigService.pipelineConfigNamed(pipelineName); if (canSchedule(pipelineConfig)) { final Pipeline pipelineInstance = pipelineScheduleQueue.createPipeline(buildCause, pipelineConfig, schedulingContext(buildCause.getApprover(), pipelineConfig, pipelineConfig.first()), goConfigService.getCurrentConfig().getMd5(), timeProvider); serverHealthService.update(stageSchedulingSuccessfulState(pipelineName.toString(), CaseInsensitiveString.str(pipelineConfig.get(0).name()))); return pipelineInstance; } } catch (PipelineNotFoundException e) { LOGGER.error("Could not find pipeline {}", pipelineName, e); pipelineScheduleQueue.clearPipeline(pipelineName); } catch (CannotScheduleException e) { pipelineScheduleQueue.clearPipeline(pipelineName); serverHealthService.update(stageSchedulingFailedState(pipelineName.toString(), e)); } catch (Exception e) { LOGGER.error("Error while scheduling pipeline {}", pipelineName, e); pipelineScheduleQueue.clearPipeline(pipelineName); } return null; }
private JobDetailPresentationModel presenter(JobInstance current) { String pipelineName = current.getIdentifier().getPipelineName(); String stageName = current.getIdentifier().getStageName(); JobInstances recent25 = jobInstanceService.latestCompletedJobs(pipelineName, stageName, current.getName()); AgentConfig agentConfig = goConfigService.agentByUuid(current.getAgentUuid()); Pipeline pipelineWithOneBuild = pipelineService.wrapBuildDetails(current); Tabs customizedTabs = goConfigService.getCustomizedTabs(pipelineWithOneBuild.getName(), pipelineWithOneBuild.getFirstStage().getName(), current.getName()); TrackingTool trackingTool = goConfigService.pipelineConfigNamed( new CaseInsensitiveString(pipelineWithOneBuild.getName())).trackingTool(); Properties properties = propertiesService.getPropertiesForJob(current.getId()); Stage stage = stageService.getStageByBuild(current); return new JobDetailPresentationModel(current, recent25, agentConfig, pipelineWithOneBuild, customizedTabs, trackingTool, artifactService, properties, stage); }