Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(connection-details): support executing from an azure devops pipeline #189

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions src/CasCap.DevOpsYamlizrCli/Commands/GenerateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public GenerateCommand(ILogger<GenerateCommand> logger, ILoggerFactory loggerFac

[Required]
[Option("-pat", Description = "Azure DevOps PAT (Personal Access Token).")]
public string PAT { get; }
public string PAT { get; set; }

[Required]
[Option("-org|--organisation", Description = "Azure DevOps Organisation Uri.")]
public string organisationUri { get; }
public string organisationUri { get; set; }

[Required]
[Option("-proj|--project", Description = "Azure DevOps Project Name.")]
Expand Down Expand Up @@ -55,13 +55,30 @@ public async Task<int> OnExecuteAsync()

if (string.IsNullOrWhiteSpace(PAT) || PAT.Trim().Length != 52)
{
_logger.LogError($"{nameof(PAT)} missing or invalid!");
return 1;
PAT = Environment.GetEnvironmentVariable("SYSTEM_ACCESSTOKEN");
if(!string.IsNullOrWhiteSpace(PAT))
{
_console.WriteLine("System.AccessToken detected using that for authentication.");
}
else
{
_logger.LogError($"{nameof(PAT)} missing or invalid!");
return 1;
}
}
if (string.IsNullOrWhiteSpace(organisationUri))
{
var collection = Environment.GetEnvironmentVariable("SYSTEM_COLLECTIONURI");
if (!string.IsNullOrWhiteSpace(collection))
{
organisationUri = collection;
_console.WriteLine("System.CollectionUri detected, extracting organization from it.");
}
else
{
_logger.LogError($"{nameof(organisationUri)} missing or invalid!");
return 1;
}
}

#region tool intro text
Expand Down