/// <summary> /// Executes the logic for this workflow activity. /// </summary> /// <param name="context">The workflow context.</param> /// <returns>The <see cref="Microsoft.TeamFoundation.Build.Client.IQueuedBuild"/> /// object that is returned after queueing the new build.</returns> protected override IQueuedBuild Execute(CodeActivityContext context) { if (context == null) { throw new ArgumentNullException("context"); } IBuildServer buildServer = context.GetValue(this.BuildServer); IBuildDefinition buildDefinition = context.GetValue(this.BuildDefinition); IBuildRequest buildRequest = buildServer.CreateBuildRequest(buildDefinition.Uri); buildRequest.Priority = context.GetValue(this.Priority); string processParameters = context.GetValue(this.ProcessParameters); if (!string.IsNullOrEmpty(processParameters)) { buildRequest.ProcessParameters = processParameters; } IBuildController buildController = context.GetValue(this.BuildController); if (buildController != null) { buildRequest.BuildController = buildController; } IQueuedBuild queuedBuild = buildServer.QueueBuild(buildRequest); return(queuedBuild); }
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(); } }
/// <summary> /// Executes the logic for this workflow activity. /// </summary> /// <returns>The <see cref="Microsoft.TeamFoundation.Build.Client.IQueuedBuild"/> /// object that is returned after queueing the new build.</returns> protected override IQueuedBuild InternalExecute() { IBuildServer buildServer = this.BuildServer.Get(this.ActivityContext); IBuildDefinition buildDefinition = this.BuildDefinition.Get(this.ActivityContext); IBuildRequest buildRequest = buildServer.CreateBuildRequest(buildDefinition.Uri); buildRequest.Priority = this.Priority.Get(this.ActivityContext); if (Enum.IsDefined(typeof(QueuePriority), buildRequest.Priority) == false) { // Set default value to normal, if no value has been passed. buildRequest.Priority = QueuePriority.Normal; } string processParameters = this.ProcessParameters.Get(this.ActivityContext); if (!string.IsNullOrEmpty(processParameters)) { buildRequest.ProcessParameters = processParameters; } IBuildController buildController = this.BuildController.Get(this.ActivityContext); if (buildController != null) { buildRequest.BuildController = buildController; } IQueuedBuild queuedBuild = buildServer.QueueBuild(buildRequest); return(queuedBuild); }
public void QueueHighBuilds(IEnumerable <Uri> buildDefinitions) { var definitions = this.buildServer.QueryBuildDefinitionsByUri(buildDefinitions.ToArray()); foreach (var bd in definitions.Where(d => d.Process != null)) { IBuildRequest buildRequest = bd.CreateBuildRequest(); buildRequest.Priority = QueuePriority.High; this.buildServer.QueueBuild(buildRequest); } }
public void Promote(int buildNumber) { IBuildRequest request = BuildDefinition.CreateBuildRequest(); IDictionary <string, object> processParams = WorkflowHelpers.DeserializeProcessParameters(request.ProcessParameters); processParams["PriorBuild"] = buildNumber.ToString(); request.ProcessParameters = WorkflowHelpers.SerializeProcessParameters(processParams); IQueuedBuild queuedBuild = BuildDefinition.BuildServer.QueueBuild(request); }
public IBuildResult Build(IBuildRequest request) { //try //{ // var project = new Project(Engine.GlobalEngine); // project.Configure(project.FullFileName); //} //catch (Exception e) //{ //} throw new NotImplementedException(); }
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(); } }
public void QueueCommitBuild() { IBuildRequest request = BuildDefinition.CreateBuildRequest(); IQueuedBuild queuedBuild = BuildDefinition.BuildServer.QueueBuild(request); }
public IQueuedBuild QueueBuild(IBuildRequest buildRequest) { return(_buildDataAccess.QueueBuild(buildRequest)); }
/// <summary> /// queue a build with the provided build request /// </summary> /// <param name="dataAccess">the implementation of the data access to use when getting the data</param> /// <param name="buildRequest"></param> public static IQueuedBuild QueueBuild(IBuildDataAccess dataAccess, IBuildRequest buildRequest) { var DAL = new Data.Build.BuildData(dataAccess); return(DAL.QueueBuild(buildRequest)); }
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); } } }