private void Validate() { string message = ""; StringBuilder messageBuilder = new StringBuilder(100); string huburl = HubUrl.Trim(); string packagesRepo = PackagesRepoUrl.Trim(); if (string.IsNullOrEmpty(packagesRepo)) { messageBuilder.AppendLine("PackagesRepoUrl is required"); } if (String.IsNullOrEmpty(huburl)) { List <string> operationList = new List <string>(3); if (DeployHubBdio || CreateHubReport || CheckPolicies) { messageBuilder.Append("Cannot perform the following operations because hub_url is empty: "); } if (DeployHubBdio) { operationList.Add("deploy BDIO"); } if (CreateHubReport) { operationList.Add("create risk report"); } if (CheckPolicies) { operationList.Add("check policies"); } if (operationList.Count > 0) { messageBuilder.AppendLine(String.Join(", ", operationList)); } } message = messageBuilder.ToString(); if (!String.IsNullOrEmpty(message)) { throw new BlackDuckIntegrationException(message); } }
public void Setup() { string projectDirectory = Directory.GetParent(ProjectPath).FullName; if (String.IsNullOrWhiteSpace(PackagesConfigPath)) { PackagesConfigPath = CreateProjectPackageConfigPath(projectDirectory); } if (!String.IsNullOrWhiteSpace(HubUrl.Trim())) { // Estabilish authenticated connection HubServerConfig hubServerConfig = BuildHubServerConfig(); RestConnection restConnection = new CredentialsResetConnection(hubServerConfig); Setup(restConnection); } if (String.IsNullOrWhiteSpace(OutputDirectory)) { string currentDirectory = Directory.GetCurrentDirectory(); OutputDirectory = $"{currentDirectory}{Path.DirectorySeparatorChar}{DEFAULT_OUTPUT_DIRECTORY}"; } if (String.IsNullOrWhiteSpace(HubProjectName)) { HubProjectName = Path.GetFileNameWithoutExtension(ProjectPath); } if (String.IsNullOrWhiteSpace(HubVersionName)) { HubVersionName = GetProjectAssemblyVersion(projectDirectory); } // Set helper properties BdioPropertyHelper bdioPropertyHelper = new BdioPropertyHelper(); BdioId = bdioPropertyHelper.CreateBdioId(HubProjectName, HubVersionName); }