private void QueueBuild() { if (string.IsNullOrEmpty(this.BuildDefinitionName)) { Log.LogError("BuildDefinitionName is required to queue a build"); return; } this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Queueing Build: {0}", this.BuildDefinitionName)); IBuildDefinition definition = this.buildServer.GetBuildDefinition(this.TeamProject, this.BuildDefinitionName); IBuildRequest request = definition.CreateBuildRequest(); if (this.DropLocation != null) { request.DropLocation = this.DropLocation; } // queue the build var queuedBuild = this.buildServer.QueueBuild(request, QueueOptions.None); // After adding the new prams, the Uri started throwing Null exceptions. // Added check to handle it if (queuedBuild.Build.Uri != null) { this.BuildUri = queuedBuild.Build.Uri.ToString(); } }
public void QueueBuild() { IBuildDefinition buildDefinition = SelectedBuildDefinition.BuildDefinition; IBuildRequest bdrequest; bdrequest = buildDefinition.CreateBuildRequest(); _buildserver.QueueBuild(bdrequest); }
private void LaunchBuild() { try { if (this.TeamProject.Expression == null) { var buildDetail = this.ActivityContext.GetExtension <IBuildDetail>(); this.TeamProject.Set(this.ActivityContext, buildDetail.TeamProject); } IBuildDefinition buildDefinition = this.bs.GetBuildDefinition(this.TeamProject.Get(this.ActivityContext), this.BuildDefinition.Get(this.ActivityContext)); IBuildRequest buildRequest = buildDefinition.CreateBuildRequest(); if (this.MSBuildArguments.Expression != null) { IDictionary <string, object> processParameters = WorkflowHelpers.DeserializeProcessParameters(buildRequest.ProcessParameters); IDictionary <string, object> definitionProcessParameters = WorkflowHelpers.DeserializeProcessParameters(buildDefinition.ProcessParameters); if (this.OverrideExistingMSBuildArguments.Get(this.ActivityContext) || !definitionProcessParameters.Keys.Contains(ProcessParameterMetadata.StandardParameterNames.MSBuildArguments)) { processParameters[ProcessParameterMetadata.StandardParameterNames.MSBuildArguments] = this.MSBuildArguments.Get(this.ActivityContext); } else { processParameters[ProcessParameterMetadata.StandardParameterNames.MSBuildArguments] = this.MSBuildArguments.Get(this.ActivityContext) + " " + definitionProcessParameters[ProcessParameterMetadata.StandardParameterNames.MSBuildArguments]; } buildRequest.ProcessParameters = WorkflowHelpers.SerializeProcessParameters(processParameters); } this.qb = this.bs.QueueBuild(buildRequest); } catch (Exception) { this.qb = null; this.LogBuildError("There is a problem with the build definition referenced"); } }
private void QueueBuild() { if (string.IsNullOrEmpty(this.BuildDefinitionName)) { Log.LogError("BuildDefinitionName is required to queue a build"); return; } this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Attempt to queue Build {0} of project {1}", this.BuildDefinitionName, this.TeamProject)); IBuildDefinition definition = this.buildServer.GetBuildDefinition(this.TeamProject, this.BuildDefinitionName); this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Identified as Build definition Id={0}", definition.Id)); IBuildRequest request = definition.CreateBuildRequest(); if (request == null) { Log.LogError(string.Format(CultureInfo.CurrentCulture, "Unable to create build request on {0}", this.TeamFoundationServerUrl)); return; } if (this.DropLocation != null) { request.DropLocation = this.DropLocation; } // queue the build var queuedBuild = this.buildServer.QueueBuild(request, QueueOptions.None); this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "The build is now in state {0}", queuedBuild.Status)); // After adding the new prams, the Uri started throwing Null exceptions. // Added check to handle it if (queuedBuild.Build != null && queuedBuild.Build.Uri != null) { this.BuildUri = queuedBuild.Build.Uri.ToString(); } }
private void QueueBuildTemplate(BuildTemplate buildTemplate, bool queueingMultiple) { IBuildDefinition buildDefinition = Context.BuildServer.GetBuildDefinition(buildTemplate.TeamProject, buildTemplate.DefinitionName); bool started = buildDefinition != null; string exc_msg = "-"; IQueuedBuild queuedBuild = null; if (started) { try { IBuildRequest request = buildDefinition.CreateBuildRequest(); //IBuildAgent buildAgent = Context.BuildServer.GetBuildAgent(new Uri(buildTemplate.BuildControllerUri)); IBuildController buildController = Context.BuildServer.GetBuildController(buildTemplate.BuildControllerName); /*request.BuildAgent = buildAgent; * request.CommandLineArguments = buildTemplate.CommandLineArguments;*/ request.BuildController = buildController; BuildProcessParameters buildProcessParameters = buildDefinition.GetBuildProcessParameters(); buildProcessParameters.MSBuildArguments = buildTemplate.CommandLineArguments; request.ProcessParameters = buildProcessParameters.SaveToXml(); request.DropLocation = buildTemplate.DefaultDropLocation; request.Postponed = buildTemplate.Postponed; request.Priority = buildTemplate.RunPriority; request.RequestedFor = Context.LoggedUser; queuedBuild = Context.BuildServer.QueueBuild(request); if (!queueingMultiple) { started = queuedBuild.WaitForBuildStart(10000, 10000); } } catch (Exception e) { exc_msg = e.Message; } } if (!queueingMultiple) { string message = started ? string.Format("Team build template '{0}' started successfully", buildTemplate.TemplateName) : string.Format("Team build template '{0}' failed to start, message: {1}", buildTemplate.TemplateName, exc_msg); ToolTipIcon icon = started ? ToolTipIcon.Info : ToolTipIcon.Warning; string caption = string.Format("Queue team build template '{0}'", buildTemplate.TemplateName); UIContext.Instance.ShowTrayTooltip(caption, message, icon, new NavigateToTeamBuildDefinitionHandler(buildTemplate)); //MessageBox.Show(message, string.Format("Queue team build template '{0}'", buildTemplate.TemplateName), MessageBoxButtons.OK, icon);); if (started && queuedBuild != null) { //this.parentControl.FocusAndSelectTeamBuild(queuedBuild); UIContext.Instance.ControlTeamBuilds.FocusAndSelectTeamBuild(queuedBuild); } } }