Skip to content

Commit 3322414

Browse files
committed
Merge branch 'release/1.0.0'
2 parents 0863c63 + 245c5d8 commit 3322414

17 files changed

+258
-60
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ Click on the build server and repository links to see the build definition or so
3636

3737
- [Documentation](https://cake-contrib.github.io/Cake.AzureDevOps)
3838

39-
## Chat Room
39+
## Discussion
4040

41-
Come join in the conversation about this addin in our Gitter Chat Room.
41+
For questions and to discuss ideas & feature requests, use the [GitHub discussions on the Cake GitHub repository](https://github.com/cake-build/cake/discussions), under the [Extension Q&A](https://github.com/cake-build/cake/discussions/categories/extension-q-a) category.
4242

43-
[![Join the chat at https://gitter.im/cake-contrib/Lobby](https://badges.gitter.im/cake-contrib/Lobby.svg)](https://gitter.im/cake-contrib/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
43+
[![Join in the discussion on the Cake repository](https://img.shields.io/badge/GitHub-Discussions-green?logo=github)](https://github.com/cake-build/cake/discussions)
4444

4545
## Contributing
4646

docs/input/_Bottom.cshtml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
<div class="github-button">
22
<a href="https://github.com/cake-contrib/Cake.AzureDevOps" target="_blank"><i class="fa fa-github"></i> GitHub</a>
33
</div>
4-
<script>
5-
((window.gitter = {}).chat = {}).options = {
6-
room: 'cake-contrib/Lobby'
7-
};
8-
</script>
9-
<script src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer></script>
4+
<div class="github-button">
5+
<a href="https://github.com/cake-build/cake/discussions" target="_blank"><i class="fa fa-comment"></i> Discussions</a>
6+
</div>
107

118
<script type="text/javascript" src="@Context.GetLink("/assets/js/anchor.min.js")"></script>
129
<script type="text/javascript" src="@Context.GetLink("/assets/js/clipboard.min.js")"></script>

recipe.cake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Environment.SetVariableNames();
44

55
BuildParameters.SetParameters(
6-
context: Context,
6+
context: Context,
77
buildSystem: BuildSystem,
88
sourceDirectoryPath: "./src",
99
title: "Cake.AzureDevOps",
@@ -19,7 +19,7 @@ BuildParameters.PrintParameters(Context);
1919
ToolSettings.SetToolSettings(
2020
context: Context,
2121
dupFinderExcludePattern: new string[] { BuildParameters.RootDirectoryPath + "/src/Cake.AzureDevOps.Tests/**/*.cs" },
22-
testCoverageFilter: "+[*]* -[xunit.*]* -[Cake.Core]* -[*.Tests]* -[Shouldly]*",
22+
testCoverageFilter: "+[*]* -[xunit.*]* -[Cake.Core]* -[Cake.Common]* -[*.Tests]* -[Cake.Testing]* -[Moq]* -[Shouldly]* -[DiffEngine]* -[EmptyFiles]*",
2323
testCoverageExcludeByAttribute: "*.ExcludeFromCodeCoverage*",
2424
testCoverageExcludeByFile: "*/*Designer.cs;*/*.g.cs;*/*.g.i.cs");
2525

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
</PropertyGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
18-
<PackageReference Include="Cake.Core" Version="0.33.0" />
19-
<PackageReference Include="Cake.Testing" Version="0.33.0" />
17+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
18+
<PackageReference Include="Cake.Core" Version="1.0.0" />
19+
<PackageReference Include="Cake.Testing" Version="1.0.0" />
2020
<PackageReference Include="Microsoft.TeamFoundationServer.Client" Version="16.143.2" />
21-
<PackageReference Include="Moq" Version="4.14.7" />
22-
<PackageReference Include="Shouldly" Version="3.0.2" />
21+
<PackageReference Include="Moq" Version="4.16.1" />
22+
<PackageReference Include="Shouldly" Version="4.0.3" />
2323
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
2424
<PackageReference Include="xunit" Version="2.4.1" />
2525
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />

src/Cake.AzureDevOps.Tests/Repos/PullRequest/CommentThread/AzureDevOpsPullRequestCommentThreadTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ public void Should_Get_Valid_Properties()
345345
prop1.ShouldNotBeEmpty();
346346
prop1.ShouldBe("way");
347347

348-
prop2.ShouldNotBeNull();
349348
prop2.ShouldBeOfType<int>();
350349
prop2.ShouldBe(2);
351350

src/Cake.AzureDevOps/AzureDevOpsAliases.Pipelines.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,5 +399,42 @@ public static IEnumerable<AzureDevOpsTestRun> AzureDevOpsBuildTestRuns(
399399
new AzureDevOpsBuild(context.Log, settings, new BuildClientFactory(), new TestManagementClientFactory())
400400
.GetTestRuns();
401401
}
402+
403+
/// <summary>
404+
/// Gets Azure Pipelines build definitions for the specified settings.
405+
/// </summary>
406+
/// <param name="context">The context.</param>
407+
/// <param name="settings">Settings for getting the build definitions.</param>
408+
/// <example>
409+
/// <para>Get build definitions running on Azure DevOps Server:</para>
410+
/// <code>
411+
/// <![CDATA[
412+
/// var buildSettings =
413+
/// new AzureDevOpsBuildsSettings(
414+
/// new Uri("http://myserver:8080/defaultcollection"),
415+
/// "MyProject",
416+
/// AzureDevOpsAuthenticationNtlm());
417+
///
418+
/// var buildDefinitions =
419+
/// AzureDevOpsBuildDefinitions(
420+
/// buildSettings);
421+
/// ]]>
422+
/// </code>
423+
/// </example>
424+
/// <returns>The build definitions or an empty list of build definitions.</returns>
425+
[CakeMethodAlias]
426+
[CakeAliasCategory("Azure Pipelines")]
427+
[CakeNamespaceImport("Cake.AzureDevOps.Pipelines")]
428+
public static IEnumerable<AzureDevOpsBuildDefinition> AzureDevOpsBuildDefinitions(
429+
this ICakeContext context,
430+
AzureDevOpsBuildsSettings settings)
431+
{
432+
context.NotNull(nameof(context));
433+
settings.NotNull(nameof(settings));
434+
435+
return AzureDevOpsBuildsDefinitionHelper.GetAzureDevOpsBuildDefinitions(
436+
context.Log,
437+
settings);
438+
}
402439
}
403440
}

src/Cake.AzureDevOps/Cake.AzureDevOps.csproj

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<PropertyGroup>
88
<DebugType>full</DebugType>
99
<DebugSymbols>true</DebugSymbols>
10+
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
1011
<CodeAnalysisRuleSet>..\Cake.AzureDevOps.ruleset</CodeAnalysisRuleSet>
1112
</PropertyGroup>
1213

@@ -15,13 +16,13 @@
1516
<Description>Addin for the Cake build automation system for working with Azure DevOps.</Description>
1617
<Authors>Pascal Berger</Authors>
1718
<Copyright>Copyright © Pascal Berger</Copyright>
18-
<PackageTags>Cake Script Azure-DevOps Azure-DevOps-Server</PackageTags>
19+
<PackageTags>cake cake-addin azure-devops azure-devops-server</PackageTags>
1920
<PackageIcon>icon.png</PackageIcon>
2021
<PackageProjectUrl>http://cake-contrib.github.io/Cake.AzureDevOps/</PackageProjectUrl>
2122
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2223
<RepositoryType>git</RepositoryType>
2324
<RepositoryUrl>https://github.com/cake-contrib/Cake.AzureDevOps.git</RepositoryUrl>
24-
<PackageReleaseNotes>https://github.com/cake-contrib/Cake.AzureDevOps/releases/tag/0.5.1</PackageReleaseNotes>
25+
<PackageReleaseNotes>https://github.com/cake-contrib/Cake.AzureDevOps/releases/tag/1.0.0</PackageReleaseNotes>
2526
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
2627
<IncludeBuildOutput>false</IncludeBuildOutput>
2728
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);PackBuildOutputs</TargetsForTfmSpecificContentInPackage>
@@ -36,8 +37,12 @@
3637
</PropertyGroup>
3738

3839
<ItemGroup>
39-
<PackageReference Include="Cake.Core" Version="0.33.0" PrivateAssets="All" />
40-
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.1" PrivateAssets="All" />
40+
<PackageReference Include="Cake.Common" Version="1.0.0" PrivateAssets="All" />
41+
<PackageReference Include="Cake.Core" Version="1.0.0" PrivateAssets="All" />
42+
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="5.0.3">
43+
<PrivateAssets>all</PrivateAssets>
44+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
45+
</PackageReference>
4146
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
4247
<PackageReference Include="Microsoft.TeamFoundationServer.Client" Version="16.143.2" PrivateAssets="All" />
4348
<PackageReference Include="Microsoft.VisualStudio.Services.InteractiveClient" Version="16.143.2" PrivateAssets="All" />

src/Cake.AzureDevOps/Pipelines/ArtifactResourceExtensions.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
namespace Cake.AzureDevOps.Pipelines
22
{
3+
using System;
4+
using Cake.Common.Build.AzurePipelines.Data;
35
using Microsoft.TeamFoundation.Build.WebApi;
46

57
/// <summary>
@@ -16,12 +18,17 @@ public static AzureDevOpsArtifactResource ToAzureDevOpsArtifactResource(this Art
1618
{
1719
artifactResource.NotNull(nameof(artifactResource));
1820

21+
if (!Enum.TryParse(artifactResource.Type, out AzurePipelinesArtifactType type))
22+
{
23+
throw new Exception($"Unexpected value for artifact type '{artifactResource.Type}'");
24+
}
25+
1926
return
2027
new AzureDevOpsArtifactResource
2128
{
2229
Data = artifactResource.Data,
2330
DownloadUrl = artifactResource.DownloadUrl,
24-
Type = artifactResource.Type,
31+
Type = type,
2532
Url = artifactResource.Url,
2633
Properties = artifactResource.Properties,
2734
};

src/Cake.AzureDevOps/Pipelines/AzureDevOpsArtifactResource.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace Cake.AzureDevOps.Pipelines
22
{
33
using System.Collections.Generic;
4+
using Cake.Common.Build.AzurePipelines.Data;
45

56
/// <summary>
67
/// Represents a resource associated with a <see cref="AzureDevOpsBuildArtifact" />.
@@ -20,7 +21,7 @@ public class AzureDevOpsArtifactResource
2021
/// <summary>
2122
/// Gets the type of the resource.
2223
/// </summary>
23-
public string Type { get; internal set; }
24+
public AzurePipelinesArtifactType Type { get; internal set; }
2425

2526
/// <summary>
2627
/// Gets the full http link to the resource.

src/Cake.AzureDevOps/Pipelines/AzureDevOpsBuild.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -441,23 +441,23 @@ public IEnumerable<AzureDevOpsBuildArtifact> GetArtifacts()
441441
/// <list type="table">
442442
/// <listheader>
443443
/// <term>Type</term>
444-
/// <description>Description</description>
444+
/// <term>Description</term>
445445
/// </listheader>
446446
/// <item>
447447
/// <term>FilePath</term>
448-
/// <description>File path type</description>
448+
/// <term>File path type</term>
449449
/// </item>
450450
/// <item>
451451
/// <term>GitRef</term>
452-
/// <description>Git reference type</description>
452+
/// <term>Git reference type</term>
453453
/// </item>
454454
/// <item>
455455
/// <term>TFVCLabel</term>
456-
/// <description>TFVC label type</description>
456+
/// <term>TFVC label type</term>
457457
/// </item>
458458
/// <item>
459459
/// <term>VersionControl</term>
460-
/// <description>Version control path type</description>
460+
/// <term>Version control path type</term>
461461
/// </item>
462462
/// </list>
463463
/// </param>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
namespace Cake.AzureDevOps.Pipelines
2+
{
3+
/// <summary>
4+
/// Representation of a build definition.
5+
/// </summary>
6+
public class AzureDevOpsBuildDefinition
7+
{
8+
/// <summary>
9+
/// Gets the ID of the build definition.
10+
/// </summary>
11+
public int Id { get; internal set; }
12+
13+
/// <summary>
14+
/// Gets the name of the build definition.
15+
/// </summary>
16+
public string Name { get; internal set; }
17+
18+
/// <summary>
19+
/// Gets the queue status.
20+
/// </summary>
21+
public AzureDevOpsDefinitionQueueStatus QueueStatus { get; internal set; }
22+
}
23+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
namespace Cake.AzureDevOps.Pipelines
2+
{
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using Cake.Core.Diagnostics;
7+
using Microsoft.TeamFoundation.Build.WebApi;
8+
9+
/// <summary>
10+
/// Provides functions for Azure DevOps build definitions.
11+
/// </summary>
12+
internal static class AzureDevOpsBuildsDefinitionHelper
13+
{
14+
/// <summary>
15+
/// Returns the build definitions for the <paramref name="settings"/>.
16+
/// </summary>
17+
/// <param name="log">The Cake log context.</param>
18+
/// <param name="settings">Settings for accessing Azure DevOps.</param>
19+
/// <returns>The build definitions for the the <paramref name="settings"/>.</returns>
20+
internal static IEnumerable<AzureDevOpsBuildDefinition> GetAzureDevOpsBuildDefinitions(
21+
ICakeLog log,
22+
AzureDevOpsBuildsSettings settings)
23+
{
24+
log.NotNull(nameof(log));
25+
settings.NotNull(nameof(settings));
26+
27+
List<BuildDefinitionReference> buildDefinitions = null;
28+
29+
using (var buildHttpClient = new BuildClientFactory().CreateBuildClient(settings.CollectionUrl, settings.Credentials))
30+
{
31+
if (settings.ProjectGuid != Guid.Empty)
32+
{
33+
buildDefinitions =
34+
buildHttpClient
35+
.GetDefinitionsAsync(settings.ProjectGuid)
36+
.ConfigureAwait(false)
37+
.GetAwaiter()
38+
.GetResult();
39+
}
40+
else if (!string.IsNullOrWhiteSpace(settings.ProjectName))
41+
{
42+
buildDefinitions =
43+
buildHttpClient
44+
.GetDefinitionsAsync(settings.ProjectName)
45+
.ConfigureAwait(false)
46+
.GetAwaiter()
47+
.GetResult();
48+
}
49+
else
50+
{
51+
throw new ArgumentOutOfRangeException(
52+
nameof(settings),
53+
"Either ProjectGuid or ProjectName needs to be set");
54+
}
55+
56+
log.Verbose(
57+
"{0} Build definitions found",
58+
buildDefinitions.Count);
59+
60+
return buildDefinitions
61+
.Select(x => x.ToAzureDevOpsBuildDefinition())
62+
.ToList();
63+
}
64+
}
65+
}
66+
}

src/Cake.AzureDevOps/Pipelines/AzureDevOpsBuildsHelper.cs

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ internal static IEnumerable<AzureDevOpsBuild> GetAzureDevOpsBuilds(
3434
authorizedIdenity.Id,
3535
authorizedIdenity.DisplayName);
3636

37-
BuildDefinitionReference buildDefinition = null;
37+
AzureDevOpsBuildDefinition buildDefinition = null;
3838

3939
if (!string.IsNullOrEmpty(settings.BuildDefinitionName))
4040
{
41-
buildDefinition = GetBuildDefinition(log, buildHttpClient, settings);
41+
buildDefinition = GetBuildDefinition(log, settings);
4242
if (buildDefinition == null)
4343
{
4444
throw new InvalidOperationException($"Build definition '{settings.BuildDefinitionName}' not found");
@@ -105,45 +105,21 @@ internal static IEnumerable<AzureDevOpsBuild> GetAzureDevOpsBuilds(
105105
/// Returns the build definition for the <paramref name="settings"/>.
106106
/// </summary>
107107
/// <param name="log">The Cake log context.</param>
108-
/// <param name="buildHttpClient">The Http build client.</param>
109108
/// <param name="settings">Settings for accessing AzureDevOps.</param>
110109
/// <returns>The build definition for the BuildDefinitionName on <paramref name="settings"/>.
111110
/// <c>null</c> if the BuildDefinitionName was not set or no build definition was found.</returns>
112-
private static BuildDefinitionReference GetBuildDefinition(
111+
private static AzureDevOpsBuildDefinition GetBuildDefinition(
113112
ICakeLog log,
114-
BuildHttpClient buildHttpClient,
115113
AzureDevOpsBuildsSettings settings)
116114
{
117115
log.NotNull(nameof(log));
118-
buildHttpClient.NotNull(nameof(buildHttpClient));
119116
settings.NotNull(nameof(settings));
120117

121-
List<BuildDefinitionReference> buildDefinitions = null;
122-
123-
if (settings.ProjectGuid != Guid.Empty)
124-
{
125-
buildDefinitions =
126-
buildHttpClient
127-
.GetDefinitionsAsync(settings.ProjectGuid)
128-
.ConfigureAwait(false)
129-
.GetAwaiter()
130-
.GetResult();
131-
}
132-
else if (!string.IsNullOrWhiteSpace(settings.ProjectName))
133-
{
134-
buildDefinitions =
135-
buildHttpClient
136-
.GetDefinitionsAsync(settings.ProjectName)
137-
.ConfigureAwait(false)
138-
.GetAwaiter()
139-
.GetResult();
140-
}
141-
else
142-
{
143-
throw new ArgumentOutOfRangeException(
144-
nameof(settings),
145-
"Either ProjectGuid or ProjectName needs to be set");
146-
}
118+
var buildDefinitions =
119+
AzureDevOpsBuildsDefinitionHelper
120+
.GetAzureDevOpsBuildDefinitions(
121+
log,
122+
settings);
147123

148124
var buildDefinition =
149125
buildDefinitions

0 commit comments

Comments
 (0)