/** * If no environments have been configured lets default them from the `FABRIC8_DEFAULT_ENVIRONMENTS` environment variable */ public static void defaultEnvironments(ProjectConfig config, String namespace) { if (config != null) { String buildName = config.getBuildName(); if (Strings.isNotBlank(buildName) && Maps.isNullOrEmpty(config.getEnvironments())) { // lets default the environments from env var String defaultEnvironmentsText = Systems.getEnvVarOrSystemProperty("FABRIC8_DEFAULT_ENVIRONMENTS", "Testing=${namespace}-testing,Staging=${namespace}-staging,Production=${namespace}-prod"); String text = Strings.replaceAllWithoutRegex(defaultEnvironmentsText, "${buildName}", buildName); text = Strings.replaceAllWithoutRegex(text, "${namespace}", namespace); LinkedHashMap<String,String> environments = Maps.parseMap(text); config.setEnvironments(environments); } } }
/** * Returns the configuration from the {@link #FILE_NAME} in the given folder or returns the default configuration */ public static ProjectConfig loadFromFolder(File folder) { File projectConfigFile = new File(folder, FILE_NAME); if (projectConfigFile != null && projectConfigFile.exists() && projectConfigFile.isFile()) { LOG.debug("Parsing fabric8 devops project configuration from: " + projectConfigFile.getName()); try { return ProjectConfigs.parseProjectConfig(projectConfigFile); } catch (IOException e) { LOG.warn("Failed to parse " + projectConfigFile + ". " + e, e); } } return new ProjectConfig(); }
flow = flowValue.toString(); config.setPipeline(flow);
config = new ProjectConfig(); if (config.isEmpty() && !hasFile) { message = "No " + fileName + " need be generated as there is no configuration"; return Results.success(message); String buildName = config.getBuildName(); if (Strings.isNotBlank(buildName)) { if (pipelineValue != null) { config.setEnvironments(environmentMap); LOG.info("Configured project " + buildName + " environments: " + config.getEnvironments()); ProjectConfigs.defaultEnvironments(config, namespace); String projectName = config.getBuildName(); if (Strings.isNullOrBlank(projectName)) { projectName = named; config.setBuildName(projectName); if (pipelineValue == null && hasLocalJenkinsFile && !config.isUseLocalFlow()) { config.setUseLocalFlow(true); } else if (config.isUseLocalFlow()) { LOG.warn("Cannot copy the pipeline to the project as it already exists in the project!"); } else { Files.writeToFile(newFile, flowText.getBytes()); LOG.info("Written pipeline to " + newFile);
if (projectConfig != null){ GitConfig gitConfig = getGitConfig(); String repoName = projectConfig.getBuildName(); String userEnvVar = "JENKINS_GOGS_USER"; String username = env.get(userEnvVar); String jobUrl = projectConfig.getLink("Job"); if (Strings.isNullOrBlank(jobUrl)) { String name = projectConfig.getBuildName(); if (Strings.isNullOrBlank(name)) { String gitUrl = projectConfig.getLinks().get("Git"); if (Strings.isNullOrBlank(gitUrl)) { listener.getLogger().println("No Job link found in fabric8.yml so we cannot set the GIT_URL");
ProjectConfig projectConfig = ProjectConfigs.findFromFolder(folder); if (projectConfig != null) { LinkedHashMap<String, String> environments = projectConfig.getEnvironments(); if (environments != null) { namespace = environments.get(environment);
CommandHelpers.setInitialComponentValue(chatRoom, config.getChatRoom()); CommandHelpers.setInitialComponentValue(issueProjectName, config.getIssueProjectName()); CommandHelpers.setInitialComponentValue(codeReview, config.getCodeReview());
if (projectConfig != null){ GitConfig gitConfig = getGitConfig(); String repoName = projectConfig.getBuildName(); String userEnvVar = "JENKINS_GOGS_USER"; String username = env.get(userEnvVar); String jobUrl = projectConfig.getLink("Job"); if (Strings.isNullOrBlank(jobUrl)) { String name = projectConfig.getBuildName(); if (Strings.isNullOrBlank(name)) { String gitUrl = projectConfig.getLinks().get("Git"); if (Strings.isNullOrBlank(gitUrl)) { listener.getLogger().println("No Job link found in fabric8.yml so we cannot set the GIT_URL");
protected void updateConfiguration(UIExecutionContext context, ProjectConfig config) { Map<Object, Object> attributeMap = context.getUIContext().getAttributeMap(); ProjectConfigs.configureProperties(config, attributeMap); Object pipelineValue = attributeMap.get("selectedPipeline"); if (pipelineValue instanceof PipelineDTO) { PipelineDTO pipeline = (PipelineDTO) pipelineValue; if (pipeline != null) { config.setPipeline(pipeline.getValue()); } } }
/** * Tries to find the project configuration from the current directory or a parent folder. * * If no fabric8.yml file can be found just return an empty configuration */ public static ProjectConfig findFromFolder(File folder) { if (folder.isDirectory()) { File projectConfigFile = new File(folder, FILE_NAME); if (projectConfigFile != null && projectConfigFile.exists() && projectConfigFile.isFile()) { return loadFromFolder(folder); } File parentFile = folder.getParentFile(); if (parentFile != null) { return findFromFolder(parentFile); } } return new ProjectConfig(); }
private static void updateConfiguration(UIExecutionContext context, ProjectConfig config) { Map<Object, Object> attributeMap = context.getUIContext().getAttributeMap(); ProjectConfigs.configureProperties(config, attributeMap); Object pipelineValue = attributeMap.get("selectedPipeline"); if (pipelineValue instanceof PipelineDTO) { PipelineDTO pipeline = (PipelineDTO) pipelineValue; if (pipeline != null) { config.setPipeline(pipeline.getValue()); } } }