Skip to content

Commit 0fc1a74

Browse files
authored
[Devex Agent] Default to finding user email for create release plan (#11384)
1 parent dacc6aa commit 0fc1a74

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

tools/azsdk-cli/Azure.Sdk.Tools.Cli/Tools/ReleasePlanTool/ReleasePlanTool.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public partial class ReleasePlanTool(IDevOpsService devOpsService, ITypeSpecHelp
2727
private const string getReleasePlanDetailsCommandName = "get";
2828
private const string createReleasePlanCommandName = "create";
2929
private const string linkNamespaceApprovalIssueCommandName = "link-namespace-approval";
30+
private const string sdkBotEmail = "[email protected]";
3031

3132
// Options
3233
private readonly Option<int> releasePlanNumberOpt = new(["--release-plan-id",], "Release Plan ID") { IsRequired = false };
@@ -204,14 +205,22 @@ public async Task<string> CreateReleasePlan(string typeSpecProjectPath, string t
204205
await ValidateCreateReleasePlanInputAsync(typeSpecProjectPath, serviceTreeId, productTreeId, specPullRequestUrl, sdkReleaseType);
205206

206207
var specType = typeSpecHelper.IsValidTypeSpecProjectPath(typeSpecProjectPath) ? "TypeSpec" : "OpenAPI";
207-
var isMgmt = typeSpecHelper.IsTypeSpecProjectForMgmtPlane(typeSpecProjectPath);
208-
209-
if (string.IsNullOrEmpty(userEmail))
208+
var isMgmt = typeSpecHelper.IsTypeSpecProjectForMgmtPlane(typeSpecProjectPath);
209+
210+
logger.LogInformation("Attempting to retrieve current user email.");
211+
212+
var email = await userHelper.GetUserEmail();
213+
if (email != sdkBotEmail)
210214
{
211-
logger.LogInformation("User email not provided. Attempting to retrieve current user email.");
212-
userEmail = await userHelper.GetUserEmail();
213-
logger.LogInformation("User email not provided. Using current user email to submit release plan: {userEmail}", userEmail);
215+
userEmail = email;
216+
logger.LogInformation("Using current user email to submit release plan: {userEmail}", userEmail);
214217
}
218+
else if (string.IsNullOrEmpty(userEmail))
219+
{
220+
throw new InvalidOperationException("Cannot create release plan using SDK bot email. Please provide a valid user email address.");
221+
}
222+
223+
logger.LogInformation("User email for release plan submission: {userEmail}", userEmail);
215224

216225
var releasePlan = new ReleasePlan
217226
{

0 commit comments

Comments
 (0)