@@ -89,6 +89,42 @@ public static AzureDevOpsBuild AzureDevOpsBuildUsingAzurePipelinesOAuthToken(
89
89
return AzureDevOpsBuild ( context , settings ) ;
90
90
}
91
91
92
+ /// <summary>
93
+ /// Gets the description of the Azure Pipelines build which is running.
94
+ /// Make sure the build has the 'Allow Scripts to access OAuth token' option enabled.
95
+ /// </summary>
96
+ /// <param name="context">The context.</param>
97
+ /// <param name="throwExceptionIfBuildCouldNotBeFound">Value indicating whether an exception
98
+ /// should be thrown if build could not be found.</param>
99
+ /// <example>
100
+ /// <para>Get current Azure Pipelines build. Don't throw exception in case the build is not found:</para>
101
+ /// <code>
102
+ /// <![CDATA[
103
+ /// var build =
104
+ /// AzureDevOpsBuildUsingAzurePipelinesOAuthToken(false);
105
+ /// ]]>
106
+ /// </code>
107
+ /// </example>
108
+ /// <returns>Description of the build.
109
+ /// Returns <c>null</c> if build could not be found and
110
+ /// <paramref name="throwExceptionIfBuildCouldNotBeFound"/> is set to <c>false</c>.</returns>
111
+ /// <exception cref="AzureDevOpsBuildNotFoundException">If build could not be found and
112
+ /// <paramref name="throwExceptionIfBuildCouldNotBeFound"/> is set to <c>true</c>.</exception>
113
+ [ CakeMethodAlias ]
114
+ [ CakeAliasCategory ( "Azure Pipelines" ) ]
115
+ [ CakeNamespaceImport ( "Cake.AzureDevOps.Pipelines" ) ]
116
+ public static AzureDevOpsBuild AzureDevOpsBuildUsingAzurePipelinesOAuthToken (
117
+ this ICakeContext context ,
118
+ bool throwExceptionIfBuildCouldNotBeFound )
119
+ {
120
+ context . NotNull ( nameof ( context ) ) ;
121
+
122
+ var settings = AzureDevOpsBuildSettings . UsingAzurePipelinesOAuthToken ( ) ;
123
+ settings . ThrowExceptionIfBuildCouldNotBeFound = throwExceptionIfBuildCouldNotBeFound ;
124
+
125
+ return AzureDevOpsBuild ( context , settings ) ;
126
+ }
127
+
92
128
/// <summary>
93
129
/// Gets the description of a specific build which is running the access token provided by Azure Pipelines.
94
130
/// Make sure the build has the 'Allow Scripts to access OAuth token' option enabled.
@@ -100,7 +136,7 @@ public static AzureDevOpsBuild AzureDevOpsBuildUsingAzurePipelinesOAuthToken(
100
136
/// <code>
101
137
/// <![CDATA[
102
138
/// var build =
103
- /// AzureDevOpsBuildUsingAzurePipelinesOAuthToken();
139
+ /// AzureDevOpsBuildUsingAzurePipelinesOAuthToken(42 );
104
140
/// ]]>
105
141
/// </code>
106
142
/// </example>
@@ -124,6 +160,45 @@ public static AzureDevOpsBuild AzureDevOpsBuildUsingAzurePipelinesOAuthToken(
124
160
return AzureDevOpsBuild ( context , settings ) ;
125
161
}
126
162
163
+ /// <summary>
164
+ /// Gets the description of a specific build which is running the access token provided by Azure Pipelines.
165
+ /// Make sure the build has the 'Allow Scripts to access OAuth token' option enabled.
166
+ /// </summary>
167
+ /// <param name="context">The context.</param>
168
+ /// <param name="buildId">ID of the build.</param>
169
+ /// <param name="throwExceptionIfBuildCouldNotBeFound">Value indicating whether an exception
170
+ /// should be thrown if build could not be found.</param>
171
+ /// <example>
172
+ /// <para>Get an Azure Pipelines build. Don't throw exception in case the build is not found:</para>
173
+ /// <code>
174
+ /// <![CDATA[
175
+ /// var build =
176
+ /// AzureDevOpsBuildUsingAzurePipelinesOAuthToken(42, false);
177
+ /// ]]>
178
+ /// </code>
179
+ /// </example>
180
+ /// <returns>Description of the build.
181
+ /// Returns <c>null</c> if build could not be found and
182
+ /// <paramref name="throwExceptionIfBuildCouldNotBeFound"/> is set to <c>false</c>.</returns>
183
+ /// <exception cref="AzureDevOpsBuildNotFoundException">If build could not be found and
184
+ /// <paramref name="throwExceptionIfBuildCouldNotBeFound"/> is set to <c>true</c>.</exception>
185
+ [ CakeMethodAlias ]
186
+ [ CakeAliasCategory ( "Azure Pipelines" ) ]
187
+ [ CakeNamespaceImport ( "Cake.AzureDevOps.Pipelines" ) ]
188
+ public static AzureDevOpsBuild AzureDevOpsBuildUsingAzurePipelinesOAuthToken (
189
+ this ICakeContext context ,
190
+ int buildId ,
191
+ bool throwExceptionIfBuildCouldNotBeFound )
192
+ {
193
+ context . NotNull ( nameof ( context ) ) ;
194
+ buildId . NotNegativeOrZero ( nameof ( buildId ) ) ;
195
+
196
+ var settings = AzureDevOpsBuildSettings . UsingAzurePipelinesOAuthToken ( buildId ) ;
197
+ settings . ThrowExceptionIfBuildCouldNotBeFound = throwExceptionIfBuildCouldNotBeFound ;
198
+
199
+ return AzureDevOpsBuild ( context , settings ) ;
200
+ }
201
+
127
202
/// <summary>
128
203
/// Gets Azure Pipelines builds using the specified settings.
129
204
/// </summary>
0 commit comments