Skip to content

Commit a98b766

Browse files
committed
Merge branch 'release/0.4.4'
2 parents 06c31df + b85f554 commit a98b766

14 files changed

+788
-122
lines changed

src/Cake.AzureDevOps.Tests/Cake.AzureDevOps.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</PropertyGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
17+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
1818
<PackageReference Include="Cake.Core" Version="0.33.0" />
1919
<PackageReference Include="Cake.Testing" Version="0.33.0" />
2020
<PackageReference Include="Microsoft.TeamFoundationServer.Client" Version="16.143.2" />

src/Cake.AzureDevOps/AzureDevOpsAliases.Pipelines.cs

Lines changed: 146 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace Cake.AzureDevOps
22
{
3+
using System.Collections.Generic;
34
using Cake.AzureDevOps.Pipelines;
45
using Cake.Core;
56
using Cake.Core.Annotations;
@@ -15,7 +16,7 @@ public static partial class AzureDevOpsAliases
1516
/// <param name="context">The context.</param>
1617
/// <param name="settings">Settings for getting the build.</param>
1718
/// <example>
18-
/// <para>Get a pull request based on the source branch:</para>
19+
/// <para>Get a build running on Azure DevOps Server:</para>
1920
/// <code>
2021
/// <![CDATA[
2122
/// var buildSettings =
@@ -76,7 +77,7 @@ public static AzureDevOpsBuild AzureDevOpsBuild(
7677
/// <exception cref="AzureDevOpsBuildNotFoundException">If build could not be found and
7778
/// <see cref="AzureDevOpsBuildSettings.ThrowExceptionIfBuildCouldNotBeFound"/> is set to <c>true</c>.</exception>
7879
[CakeMethodAlias]
79-
[CakeAliasCategory("Build")]
80+
[CakeAliasCategory("Azure Pipelines")]
8081
[CakeNamespaceImport("Cake.AzureDevOps.Pipelines")]
8182
public static AzureDevOpsBuild AzureDevOpsBuildUsingAzurePipelinesOAuthToken(
8283
this ICakeContext context)
@@ -87,5 +88,148 @@ public static AzureDevOpsBuild AzureDevOpsBuildUsingAzurePipelinesOAuthToken(
8788

8889
return AzureDevOpsBuild(context, settings);
8990
}
91+
92+
/// <summary>
93+
/// Returns if the Azure DevOps build is failing.
94+
/// </summary>
95+
/// <param name="context">The context.</param>
96+
/// <param name="settings">Settings for getting the build.</param>
97+
/// <example>
98+
/// <para>Get changes associated with an Azure Pipelines build:</para>
99+
/// <code>
100+
/// <![CDATA[
101+
/// var buildSettings =
102+
/// new AzureDevOpsBuildSettings(
103+
/// new Uri("http://myserver:8080/defaultcollection"),
104+
/// "MyProject",
105+
/// 42,
106+
/// AzureDevOpsAuthenticationNtlm());
107+
///
108+
/// var isFailing =
109+
/// AzureDevOpsBuildIsFailing(
110+
/// buildSettings);
111+
///
112+
/// if (isFailing)
113+
/// {
114+
/// Information("Build is failing");
115+
/// }
116+
/// ]]>
117+
/// </code>
118+
/// </example>
119+
/// <returns>The changes associated with the build.
120+
/// Returns an empty list if build could not be found and
121+
/// <see cref="AzureDevOpsBuildSettings.ThrowExceptionIfBuildCouldNotBeFound"/> is set to <c>false</c>.</returns>
122+
/// <exception cref="AzureDevOpsBuildNotFoundException">If build could not be found and
123+
/// <see cref="AzureDevOpsBuildSettings.ThrowExceptionIfBuildCouldNotBeFound"/> is set to <c>true</c>.</exception>
124+
[CakeMethodAlias]
125+
[CakeAliasCategory("Azure Pipelines")]
126+
[CakeNamespaceImport("Cake.AzureDevOps.Pipelines")]
127+
public static bool AzureDevOpsBuildIsFailing(
128+
this ICakeContext context,
129+
AzureDevOpsBuildSettings settings)
130+
{
131+
context.NotNull(nameof(context));
132+
settings.NotNull(nameof(settings));
133+
134+
return
135+
new AzureDevOpsBuild(context.Log, settings, new BuildClientFactory())
136+
.IsBuildFailing();
137+
}
138+
139+
/// <summary>
140+
/// Gets the changes associated with an Azure Pipelines build.
141+
/// </summary>
142+
/// <param name="context">The context.</param>
143+
/// <param name="settings">Settings for getting the build.</param>
144+
/// <example>
145+
/// <para>Get changes associated with an Azure Pipelines build:</para>
146+
/// <code>
147+
/// <![CDATA[
148+
/// var buildSettings =
149+
/// new AzureDevOpsBuildSettings(
150+
/// new Uri("http://myserver:8080/defaultcollection"),
151+
/// "MyProject",
152+
/// 42,
153+
/// AzureDevOpsAuthenticationNtlm());
154+
///
155+
/// var changes =
156+
/// AzureDevOpsBuildChanges(
157+
/// buildSettings);
158+
///
159+
/// Information("Changes:");
160+
/// foreach (var change in changes)
161+
/// {
162+
/// Information(" {0}: {1}", change.Id, change.Message);
163+
/// }
164+
/// ]]>
165+
/// </code>
166+
/// </example>
167+
/// <returns>The changes associated with the build.
168+
/// Returns an empty list if build could not be found and
169+
/// <see cref="AzureDevOpsBuildSettings.ThrowExceptionIfBuildCouldNotBeFound"/> is set to <c>false</c>.</returns>
170+
/// <exception cref="AzureDevOpsBuildNotFoundException">If build could not be found and
171+
/// <see cref="AzureDevOpsBuildSettings.ThrowExceptionIfBuildCouldNotBeFound"/> is set to <c>true</c>.</exception>
172+
[CakeMethodAlias]
173+
[CakeAliasCategory("Azure Pipelines")]
174+
[CakeNamespaceImport("Cake.AzureDevOps.Pipelines")]
175+
public static IEnumerable<AzureDevOpsChange> AzureDevOpsBuildChanges(
176+
this ICakeContext context,
177+
AzureDevOpsBuildSettings settings)
178+
{
179+
context.NotNull(nameof(context));
180+
settings.NotNull(nameof(settings));
181+
182+
return
183+
new AzureDevOpsBuild(context.Log, settings, new BuildClientFactory())
184+
.GetChanges();
185+
}
186+
187+
/// <summary>
188+
/// Gets the timeline entries for an Azure Pipelines build.
189+
/// </summary>
190+
/// <param name="context">The context.</param>
191+
/// <param name="settings">Settings for getting the build.</param>
192+
/// <example>
193+
/// <para>Get timeline entries for an Azure Pipelines build:</para>
194+
/// <code>
195+
/// <![CDATA[
196+
/// var buildSettings =
197+
/// new AzureDevOpsBuildSettings(
198+
/// new Uri("http://myserver:8080/defaultcollection"),
199+
/// "MyProject",
200+
/// 42,
201+
/// AzureDevOpsAuthenticationNtlm());
202+
///
203+
/// var timelineRecords =
204+
/// AzureDevOpsBuildTimelineRecords(
205+
/// buildSettings);
206+
///
207+
/// Information("Timeline:");
208+
/// foreach (var timelineRecord in timelineRecords)
209+
/// {
210+
/// Information(" {0}: {1}", timelineRecord.Name, timelineRecord.Result);
211+
/// }
212+
/// ]]>
213+
/// </code>
214+
/// </example>
215+
/// <returns>The timeline entries for the build.
216+
/// Returns an empty list if build could not be found and
217+
/// <see cref="AzureDevOpsBuildSettings.ThrowExceptionIfBuildCouldNotBeFound"/> is set to <c>false</c>.</returns>
218+
/// <exception cref="AzureDevOpsBuildNotFoundException">If build could not be found and
219+
/// <see cref="AzureDevOpsBuildSettings.ThrowExceptionIfBuildCouldNotBeFound"/> is set to <c>true</c>.</exception>
220+
[CakeMethodAlias]
221+
[CakeAliasCategory("Azure Pipelines")]
222+
[CakeNamespaceImport("Cake.AzureDevOps.Pipelines")]
223+
public static IEnumerable<AzureDevOpsTimelineRecord> AzureDevOpsBuildTimelineRecords(
224+
this ICakeContext context,
225+
AzureDevOpsBuildSettings settings)
226+
{
227+
context.NotNull(nameof(context));
228+
settings.NotNull(nameof(settings));
229+
230+
return
231+
new AzureDevOpsBuild(context.Log, settings, new BuildClientFactory())
232+
.GetTimelineRecords();
233+
}
90234
}
91235
}

src/Cake.AzureDevOps/AzureDevOpsAliases.PullRequest.cs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
namespace Cake.AzureDevOps
22
{
33
using System;
4+
using System.Collections.Generic;
45
using Cake.AzureDevOps.PullRequest;
6+
using Cake.AzureDevOps.Repos;
57
using Cake.Core;
68
using Cake.Core.Annotations;
79

@@ -126,6 +128,12 @@ public static AzureDevOpsPullRequest AzureDevOpsPullRequestUsingAzurePipelinesOA
126128
context.NotNull(nameof(context));
127129

128130
var settings = AzureDevOpsPullRequestSettings.UsingAzurePipelinesOAuthToken(throwExceptionIfPullRequestCouldNotBeFound);
131+
132+
if (settings == null)
133+
{
134+
return null;
135+
}
136+
129137
settings.ThrowExceptionIfPullRequestCouldNotBeFound = throwExceptionIfPullRequestCouldNotBeFound;
130138

131139
return AzureDevOpsPullRequest(context, settings);
@@ -263,6 +271,56 @@ public static void AzureDevOpsAddCommentToPullRequest(
263271
.CreateComment(comment);
264272
}
265273

274+
/// <summary>
275+
/// Gets the commits contained in the Azure DevOps pull request using
276+
/// the specified settings.
277+
/// </summary>
278+
/// <param name="context">The context.</param>
279+
/// <param name="settings">Settings for accessing the pull request.</param>
280+
/// <example>
281+
/// <para>Lists id and message of commits of a pull request:</para>
282+
/// <code>
283+
/// <![CDATA[
284+
/// var pullRequestSettings =
285+
/// new AzureDevOpsPullRequestSettings(
286+
/// new Uri("http://myserver:8080/defaultcollection/myproject/_git/myrepository"),
287+
/// "refs/heads/feature/myfeature",
288+
/// AzureDevOpsAuthenticationNtlm());
289+
///
290+
/// var commits =
291+
/// AzureDevOpsGetPullRequestCommits(
292+
/// pullRequestSettings);
293+
///
294+
/// Information("Commits");
295+
/// foreach (var commit in commits)
296+
/// {
297+
/// Information(" {0}: {1}", commit.Id, commit.Message);
298+
/// }
299+
/// ]]>
300+
/// </code>
301+
/// </example>
302+
/// <returns>The commits contained in the pull request.
303+
/// Returns an empty list if pull request could not be found and
304+
/// <see cref="AzureDevOpsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>false</c>.</returns>
305+
/// <exception cref="AzureDevOpsPullRequestNotFoundException">If pull request could not be found and
306+
/// <see cref="AzureDevOpsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>true</c>.</exception>
307+
[CakeMethodAlias]
308+
[CakeAliasCategory("Pull Request")]
309+
[CakeNamespaceImport("Cake.AzureDevOps.Repos")]
310+
[CakeNamespaceImport("Cake.AzureDevOps.PullRequest")]
311+
[CakeNamespaceImport("Cake.AzureDevOps.PullRequest.CommentThread")]
312+
public static IEnumerable<AzureDevOpsCommit> AzureDevOpsGetPullRequestCommits(
313+
this ICakeContext context,
314+
AzureDevOpsPullRequestSettings settings)
315+
{
316+
context.NotNull(nameof(context));
317+
settings.NotNull(nameof(settings));
318+
319+
return
320+
new AzureDevOpsPullRequest(context.Log, settings, new GitClientFactory())
321+
.GetCommits();
322+
}
323+
266324
/// <summary>
267325
/// Creates a pull request in Azure DevOps using the specified settings.
268326
/// </summary>

src/Cake.AzureDevOps/Cake.AzureDevOps.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2222
<RepositoryType>git</RepositoryType>
2323
<RepositoryUrl>https://github.com/cake-contrib/Cake.AzureDevOps.git</RepositoryUrl>
24-
<PackageReleaseNotes>https://github.com/cake-contrib/Cake.AzureDevOps/releases/tag/0.4.3</PackageReleaseNotes>
24+
<PackageReleaseNotes>https://github.com/cake-contrib/Cake.AzureDevOps/releases/tag/0.4.4</PackageReleaseNotes>
2525
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
2626
<IncludeBuildOutput>false</IncludeBuildOutput>
2727
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);PackBuildOutputs</TargetsForTfmSpecificContentInPackage>

0 commit comments

Comments
 (0)