1
1
namespace Cake . AzureDevOps
2
2
{
3
+ using System . Collections . Generic ;
3
4
using Cake . AzureDevOps . Pipelines ;
4
5
using Cake . Core ;
5
6
using Cake . Core . Annotations ;
@@ -15,7 +16,7 @@ public static partial class AzureDevOpsAliases
15
16
/// <param name="context">The context.</param>
16
17
/// <param name="settings">Settings for getting the build.</param>
17
18
/// <example>
18
- /// <para>Get a pull request based on the source branch :</para>
19
+ /// <para>Get a build running on Azure DevOps Server :</para>
19
20
/// <code>
20
21
/// <![CDATA[
21
22
/// var buildSettings =
@@ -76,7 +77,7 @@ public static AzureDevOpsBuild AzureDevOpsBuild(
76
77
/// <exception cref="AzureDevOpsBuildNotFoundException">If build could not be found and
77
78
/// <see cref="AzureDevOpsBuildSettings.ThrowExceptionIfBuildCouldNotBeFound"/> is set to <c>true</c>.</exception>
78
79
[ CakeMethodAlias ]
79
- [ CakeAliasCategory ( "Build " ) ]
80
+ [ CakeAliasCategory ( "Azure Pipelines " ) ]
80
81
[ CakeNamespaceImport ( "Cake.AzureDevOps.Pipelines" ) ]
81
82
public static AzureDevOpsBuild AzureDevOpsBuildUsingAzurePipelinesOAuthToken (
82
83
this ICakeContext context )
@@ -87,5 +88,148 @@ public static AzureDevOpsBuild AzureDevOpsBuildUsingAzurePipelinesOAuthToken(
87
88
88
89
return AzureDevOpsBuild ( context , settings ) ;
89
90
}
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
+ }
90
234
}
91
235
}
0 commit comments