|
1 | 1 | namespace Cake.AzureDevOps
|
2 | 2 | {
|
3 |
| - using System.Collections.Generic; |
4 | 3 | using Cake.AzureDevOps.Pipelines;
|
5 | 4 | using Cake.Core;
|
6 | 5 | using Cake.Core.Annotations;
|
| 6 | + using System.Collections.Generic; |
7 | 7 |
|
8 | 8 | /// <content>
|
9 | 9 | /// Contains functionality related to Azure Pipeline builds.
|
@@ -331,6 +331,54 @@ public static IEnumerable<AzureDevOpsChange> AzureDevOpsBuildChanges(
|
331 | 331 | .GetChanges();
|
332 | 332 | }
|
333 | 333 |
|
| 334 | + /// <summary> |
| 335 | + /// Gets the work item ids associated with an Azure Pipelines build. |
| 336 | + /// </summary> |
| 337 | + /// <param name="context">The context.</param> |
| 338 | + /// <param name="settings">Settings for getting the build.</param> |
| 339 | + /// <example> |
| 340 | + /// <para>Get work item ids associated with an Azure Pipelines build:</para> |
| 341 | + /// <code> |
| 342 | + /// <![CDATA[ |
| 343 | + /// var buildSettings = |
| 344 | + /// new AzureDevOpsBuildSettings( |
| 345 | + /// new Uri("http://myserver:8080/defaultcollection"), |
| 346 | + /// "MyProject", |
| 347 | + /// 42, |
| 348 | + /// AzureDevOpsAuthenticationNtlm()); |
| 349 | + /// |
| 350 | + /// var workItemIds = |
| 351 | + /// AzureDevOpsBuildWorkItemIds( |
| 352 | + /// buildSettings); |
| 353 | + /// |
| 354 | + /// Information("Work item ids:"); |
| 355 | + /// foreach (var id in workItemIds) |
| 356 | + /// { |
| 357 | + /// Information(" {0}", id); |
| 358 | + /// } |
| 359 | + /// ]]> |
| 360 | + /// </code> |
| 361 | + /// </example> |
| 362 | + /// <returns>The work item ids associated with the build. |
| 363 | + /// Returns an empty list if build could not be found and |
| 364 | + /// <see cref="AzureDevOpsBuildSettings.ThrowExceptionIfBuildCouldNotBeFound"/> is set to <c>false</c>.</returns> |
| 365 | + /// <exception cref="AzureDevOpsBuildNotFoundException">If build could not be found and |
| 366 | + /// <see cref="AzureDevOpsBuildSettings.ThrowExceptionIfBuildCouldNotBeFound"/> is set to <c>true</c>.</exception> |
| 367 | + [CakeMethodAlias] |
| 368 | + [CakeAliasCategory("Azure Pipelines")] |
| 369 | + [CakeNamespaceImport("Cake.AzureDevOps.Pipelines")] |
| 370 | + public static IEnumerable<int> AzureDevOpsBuildWorkItemIds( |
| 371 | + this ICakeContext context, |
| 372 | + AzureDevOpsBuildSettings settings) |
| 373 | + { |
| 374 | + context.NotNull(nameof(context)); |
| 375 | + settings.NotNull(nameof(settings)); |
| 376 | + |
| 377 | + return |
| 378 | + new AzureDevOpsBuild(context.Log, settings, new BuildClientFactory(), new TestManagementClientFactory()) |
| 379 | + .GetWorkItemIds(); |
| 380 | + } |
| 381 | + |
334 | 382 | /// <summary>
|
335 | 383 | /// Gets the timeline entries for an Azure Pipelines build.
|
336 | 384 | /// </summary>
|
|
0 commit comments