private String invokeWorkflow(IBuildDetail BuildDetail, String SonarRunnerPath = null, String LocalSolutionPath = null, bool GeneratePropertiesIfMissing = false, String TemplatePropertiesPath = null, bool FailBuildOnError = true, bool FailBuildOnAlert = false, String RunnerCmdFile = "fake-runner.cmd", StringList SonarProperties = null, String BinariesDirectory = "BinDir") { // Default values that work if (SonarRunnerPath == null) SonarRunnerPath = Path.Combine(TestContext.DeploymentDirectory, RunnerCmdFile); if (LocalSolutionPath == null) LocalSolutionPath = Path.Combine(TestContext.DeploymentDirectory, "Dummy.sln"); if (TemplatePropertiesPath == null) TemplatePropertiesPath = Path.Combine(TestContext.DeploymentDirectory, "sonar-properties.template"); ShimWorkspace workpace = new ShimWorkspace() { GetLocalItemForServerItemString = (s) => LocalSolutionPath }; // constants (literals) var activity = new Sonar { SonarRunnerPath = SonarRunnerPath, FailBuildOnError = FailBuildOnError, GeneratePropertiesIfMissing = GeneratePropertiesIfMissing, SonarPropertiesTemplatePath = TemplatePropertiesPath, FailBuildOnAlert = FailBuildOnAlert, BinariesDirectory = BinariesDirectory }; // object variables var parameters = new Dictionary<string, object> { { "BuildWorkspace", workpace.Instance }, { "ProjectsToAnalyze", new StringList("dummy.sln") } }; if (SonarProperties == null) SonarProperties = new StringList(); if (SonarProperties != null) parameters.Add("SonarProperties", SonarProperties); var workflowLogger = new BuildMessageTrackingParticipant(); // Create a WorkflowInvoker and add the IBuildDetail Extension WorkflowInvoker invoker = new WorkflowInvoker(activity); invoker.Extensions.Add(BuildDetail); invoker.Extensions.Add(workflowLogger); invoker.Invoke(parameters); return workflowLogger.ToString(); }
/// <summary>The setup TFS shim.</summary> /// <param name="collectionUrl">The collection URL.</param> /// <param name="teamProjectName">The team project name.</param> /// <param name="changesetId">The change set id.</param> /// <param name="pendingChangeCount">The pending change count.</param> private void SetupTfsShim( string collectionUrl, string teamProjectName, int changesetId, int pendingChangeCount) { ShimTfsTeamProjectCollection.ConstructorUri = (@this, value) => { // ReSharper disable ObjectCreationAsStatement new ShimTfsTeamProjectCollection(@this) { NameGet = () => collectionUrl }; new ShimTfsConnection(@this) { EnsureAuthenticated = () => { }, CredentialsGet = () => new System.Net.NetworkCredential("testUser", "pwd", "testDomain") }; // ReSharper restore ObjectCreationAsStatement }; var workspace = new ShimWorkspace { CheckInPendingChangeArrayString = (x, y) => changesetId, Delete = () => true, GetPendingChanges = () => new PendingChange[pendingChangeCount], }; var teamProject = new ShimTeamProject { ServerItemGet = () => string.Format("$/{0}", teamProjectName) }; var versionControlServer = new ShimVersionControlServer { CreateWorkspaceStringStringStringWorkingFolderArray = (a, b, c, d) => workspace, QueryWorkspacesStringStringString = (a, b, c) => new Workspace[0], GetTeamProjectString = a => teamProject, QueryBranchObjectsItemIdentifierRecursionType = (a, b) => new BranchObject[0], SupportedFeaturesGet = () => 8, ServerItemExistsStringItemType = (x, y) => true }; ShimTfsConnection.AllInstances.GetServiceOf1<VersionControlServer>(t => versionControlServer); }
private String invokeWorkflow(IBuildDetail BuildDetail, String SonarRunnerPath = null, String LocalSolutionPath = null, bool GeneratePropertiesIfMissing = false, String TemplatePropertiesPath = null, bool FailBuildOnError = true, bool FailBuildOnAlert = false, String RunnerCmdFile = "fake-runner.cmd", StringList SonarProperties = null, String BinariesDirectory = "BinDir") { // Default values that work if (SonarRunnerPath == null) { SonarRunnerPath = Path.Combine(TestContext.DeploymentDirectory, RunnerCmdFile); } if (LocalSolutionPath == null) { LocalSolutionPath = Path.Combine(TestContext.DeploymentDirectory, "Dummy.sln"); } if (TemplatePropertiesPath == null) { TemplatePropertiesPath = Path.Combine(TestContext.DeploymentDirectory, "sonar-properties.template"); } ShimWorkspace workpace = new ShimWorkspace() { GetLocalItemForServerItemString = (s) => LocalSolutionPath }; // constants (literals) var activity = new Sonar { SonarRunnerPath = SonarRunnerPath, FailBuildOnError = FailBuildOnError, GeneratePropertiesIfMissing = GeneratePropertiesIfMissing, SonarPropertiesTemplatePath = TemplatePropertiesPath, FailBuildOnAlert = FailBuildOnAlert, BinariesDirectory = BinariesDirectory }; // object variables var parameters = new Dictionary <string, object> { { "BuildWorkspace", workpace.Instance }, { "ProjectsToAnalyze", new StringList("dummy.sln") } }; if (SonarProperties == null) { SonarProperties = new StringList(); } if (SonarProperties != null) { parameters.Add("SonarProperties", SonarProperties); } var workflowLogger = new BuildMessageTrackingParticipant(); // Create a WorkflowInvoker and add the IBuildDetail Extension WorkflowInvoker invoker = new WorkflowInvoker(activity); invoker.Extensions.Add(BuildDetail); invoker.Extensions.Add(workflowLogger); invoker.Invoke(parameters); return(workflowLogger.ToString()); }