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

L1 Testing #2806

Merged
merged 84 commits into from
Feb 25, 2020
Merged
Show file tree
Hide file tree
Changes from 79 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
bf63a36
Initial work setting up the test framework
alex-peck Feb 10, 2020
9c587f2
Only execute l1s when called
Feb 11, 2020
e16b613
New mocks. Tests are now able to run
alex-peck Feb 11, 2020
fef48d7
Improve timeline record handling and fix up template JSON blob
alex-peck Feb 11, 2020
e907cf7
default
alex-peck Feb 11, 2020
3326b4c
Add ability to mock Build and Release servers
alex-peck Feb 12, 2020
2801759
Allow test writers to get mocked services
alex-peck Feb 12, 2020
86354c2
Get tasks to right directory
Feb 12, 2020
3c70225
Instantiate _mockedServices
Feb 12, 2020
61f2c0a
Return task zip stream
Feb 12, 2020
b7e5b5e
Tasks fix
alex-peck Feb 12, 2020
73a8b1b
L1HostContext
alex-peck Feb 12, 2020
b6ff75b
Use different working directories for each test
alex-peck Feb 12, 2020
7e07c24
Get exe plumbed into Bin directory
Feb 13, 2020
f747c50
E2E test running
Feb 18, 2020
cebc7af
Mock plugins
Feb 19, 2020
a6e66e9
Added a few base tests
alex-peck Feb 19, 2020
4f9342e
Cleanup
alex-peck Feb 19, 2020
3144095
Source providers
Feb 19, 2020
4c99882
Merge branch 'feature/l1-tests' of https://github.com/microsoft/azure…
Feb 19, 2020
864d5d1
Fix timeout
alex-peck Feb 19, 2020
9e10506
Fix test checks and add l1 to ci
Feb 20, 2020
9ee6d4d
Naming
Feb 20, 2020
a1c0562
Remove unecessary translation strings from test task
alex-peck Feb 20, 2020
d880ef7
Merge branch 'feature/l1-tests' of https://github.com/microsoft/azure…
alex-peck Feb 20, 2020
354c8c4
Style nit
Feb 20, 2020
6b48c6c
Dont double call l1s
Feb 20, 2020
d7f82d7
Fix L0 run
alex-peck Feb 20, 2020
06dd724
Merge branch 'feature/l1-tests' of https://github.com/microsoft/azure…
alex-peck Feb 20, 2020
cf112e9
skip arm l1s
Feb 20, 2020
4047887
Merge branch 'feature/l1-tests' of https://github.com/microsoft/azure…
Feb 20, 2020
30c899e
Conditions are hard
Feb 20, 2020
4fcaeff
Output test logs as artifacts
alex-peck Feb 20, 2020
cb6aabc
Merge branch 'feature/l1-tests' of https://github.com/microsoft/azure…
alex-peck Feb 20, 2020
be7194f
Mock customer intelligence events
alex-peck Feb 20, 2020
c6170e1
missing file
alex-peck Feb 20, 2020
23872cd
Dummy vso-task-lib
Feb 20, 2020
6ebe9bb
Copy full package.json
Feb 20, 2020
250ab25
Load externals for l1
Feb 20, 2020
676ae2d
webpacked version
Feb 20, 2020
a26fcb4
Never localize with webpack and task-lib
Feb 20, 2020
a4c9d7d
Revert task and no spaces in sh
Feb 20, 2020
77ebb52
Auto install npm
Feb 20, 2020
7c3a8f3
npm install on all directories
Feb 20, 2020
19a525c
QUotes for vso commands and system.debug
alex-peck Feb 20, 2020
9a4bce6
Merge branch 'feature/l1-tests' of https://github.com/microsoft/azure…
alex-peck Feb 20, 2020
6e7575b
Better install message
Feb 20, 2020
29bc1e9
Try newer version of npm
Feb 20, 2020
71560b2
Try special casing rhel6
Feb 20, 2020
82032fd
Typo
Feb 20, 2020
ed14b31
Permissions
Feb 20, 2020
a27c7c1
Dont special case rhel6
Feb 20, 2020
4b73b8c
Special case rhel6
Feb 20, 2020
c09d3e6
Fix symlink
Feb 20, 2020
165d6ff
Fix symlink
Feb 21, 2020
772ee49
Try installing legacy node
Feb 21, 2020
b73eaae
Fix symlink
Feb 21, 2020
16eb2fd
Fix symlink
Feb 21, 2020
7bcf640
run as sudo
Feb 21, 2020
604164d
Undo run as sudo
Feb 21, 2020
f2de60a
Permissions
Feb 21, 2020
2446cc6
Permissions
Feb 21, 2020
c1ec3eb
Permissions
Feb 21, 2020
9c01b9a
Try adding node to path
Feb 21, 2020
67eb575
Fix path
Feb 21, 2020
62b2dea
Fix path
Feb 21, 2020
5d0673e
Add explanatory comment
Feb 21, 2020
7b31f0c
Remove extra task stuff
Feb 21, 2020
20070a0
Use tasks from endpoint
Feb 24, 2020
5937e0d
merge
Feb 24, 2020
66fa916
Get system zipping
Feb 24, 2020
245ded3
Break up tests into their categories instead of putting them all in o…
alex-peck Feb 24, 2020
16f1285
Missing test
alex-peck Feb 24, 2020
3f87bec
Fix race condition
Feb 24, 2020
4175ce8
Merge branch 'feature/l1-tests' of https://github.com/microsoft/azure…
Feb 24, 2020
e67cced
cleanup
Feb 24, 2020
9e48bff
Get rid of bad lock
Feb 24, 2020
68bd940
Revert "Get rid of bad lock"
alex-peck Feb 24, 2020
3acde54
un-nit
alex-peck Feb 25, 2020
f3f918c
Remove setter
Feb 25, 2020
f0303c4
nits
alex-peck Feb 25, 2020
b30fa76
Helper ReplacePlugin method
Feb 25, 2020
522d0f6
Merge branch 'feature/l1-tests' of https://github.com/microsoft/azure…
Feb 25, 2020
3a92972
Nits
Feb 25, 2020
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
**/.vscode
**/*.error
**/*.json.pretty
node_modules
**/node_modules
_downloads
_layout
_l1
_package
_reports
_dotnetsdk
Expand Down
9 changes: 7 additions & 2 deletions .vsts.template.nonwindows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ steps:
displayName: Build & Layout Release

# Run test
- script: ./dev.sh test
- script: ./dev.sh testl0
workingDirectory: src
displayName: Test
displayName: Unit tests

- script: ./dev.sh testl1
workingDirectory: src
displayName: Functional tests
damccorm marked this conversation as resolved.
Show resolved Hide resolved
condition: ne('${{ parameters.testLogTitle }}', 'Linux-ARM')

# Publish test results
- task: PublishTestResults@2
Expand Down
8 changes: 6 additions & 2 deletions .vsts.template.windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ steps:
displayName: Build & Layout Release

# Run test
- script: dev.cmd test
- script: dev.cmd testl0
workingDirectory: src
displayName: Test
displayName: Unit tests

- script: dev.cmd testl1
workingDirectory: src
displayName: Functional tests

# Publish test results
- task: PublishTestResults@2
Expand Down
22 changes: 11 additions & 11 deletions src/Agent.Plugins/GitCliManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ private static Encoding _encoding
: null;
}

private readonly Dictionary<string, string> gitEnv = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
protected readonly Dictionary<string, string> gitEnv = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
damccorm marked this conversation as resolved.
Show resolved Hide resolved
{
{ "GIT_TERMINAL_PROMPT", "0" },
};

private string gitPath = null;
private Version gitVersion = null;
private string gitLfsPath = null;
private Version gitLfsVersion = null;
protected string gitPath = null;
protected Version gitVersion = null;
protected string gitLfsPath = null;
protected Version gitLfsVersion = null;

public GitCliManager(Dictionary<string, string> envs = null)
{
Expand Down Expand Up @@ -76,7 +76,7 @@ public bool EnsureGitLFSVersion(Version requiredVersion, bool throwOnNotMatch)
return gitLfsVersion >= requiredVersion;
}

public async Task LoadGitExecutionInfo(AgentTaskPluginExecutionContext context, bool useBuiltInGit)
public virtual async Task LoadGitExecutionInfo(AgentTaskPluginExecutionContext context, bool useBuiltInGit)
{
// There is no built-in git for OSX/Linux
gitPath = null;
Expand Down Expand Up @@ -495,7 +495,7 @@ public async Task<int> GitLFSLogs(AgentTaskPluginExecutionContext context, strin
}

// git version
public async Task<Version> GitVersion(AgentTaskPluginExecutionContext context)
public virtual async Task<Version> GitVersion(AgentTaskPluginExecutionContext context)
{
context.Debug("Get git version.");
string workingDir = context.Variables.GetValueOrDefault("agent.workfolder")?.Value;
Expand Down Expand Up @@ -528,7 +528,7 @@ public async Task<Version> GitVersion(AgentTaskPluginExecutionContext context)
}

// git lfs version
public async Task<Version> GitLfsVersion(AgentTaskPluginExecutionContext context)
public virtual async Task<Version> GitLfsVersion(AgentTaskPluginExecutionContext context)
{
context.Debug("Get git-lfs version.");
string workingDir = context.Variables.GetValueOrDefault("agent.workfolder")?.Value;
Expand Down Expand Up @@ -560,7 +560,7 @@ public async Task<Version> GitLfsVersion(AgentTaskPluginExecutionContext context
return version;
}

private async Task<int> ExecuteGitCommandAsync(AgentTaskPluginExecutionContext context, string repoRoot, string command, string options, CancellationToken cancellationToken = default(CancellationToken))
protected virtual async Task<int> ExecuteGitCommandAsync(AgentTaskPluginExecutionContext context, string repoRoot, string command, string options, CancellationToken cancellationToken = default(CancellationToken))
{
string arg = StringUtil.Format($"{command} {options}").Trim();
context.Command($"git {arg}");
Expand All @@ -586,7 +586,7 @@ public async Task<Version> GitLfsVersion(AgentTaskPluginExecutionContext context
cancellationToken: cancellationToken);
}

private async Task<int> ExecuteGitCommandAsync(AgentTaskPluginExecutionContext context, string repoRoot, string command, string options, IList<string> output)
protected virtual async Task<int> ExecuteGitCommandAsync(AgentTaskPluginExecutionContext context, string repoRoot, string command, string options, IList<string> output)
{
string arg = StringUtil.Format($"{command} {options}").Trim();
context.Command($"git {arg}");
Expand Down Expand Up @@ -617,7 +617,7 @@ private async Task<int> ExecuteGitCommandAsync(AgentTaskPluginExecutionContext c
cancellationToken: default(CancellationToken));
}

private async Task<int> ExecuteGitCommandAsync(AgentTaskPluginExecutionContext context, string repoRoot, string command, string options, string additionalCommandLine, CancellationToken cancellationToken)
protected virtual async Task<int> ExecuteGitCommandAsync(AgentTaskPluginExecutionContext context, string repoRoot, string command, string options, string additionalCommandLine, CancellationToken cancellationToken)
{
string arg = StringUtil.Format($"{additionalCommandLine} {command} {options}").Trim();
context.Command($"git {arg}");
Expand Down
15 changes: 10 additions & 5 deletions src/Agent.Plugins/GitSourceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public override void RequirementCheck(AgentTaskPluginExecutionContext executionC
}
}

public sealed class BitbucketGitSourceProvider : AuthenticatedGitSourceProvider
public class BitbucketGitSourceProvider : AuthenticatedGitSourceProvider
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going through this sequentially, do we need to derive from these classes? Feels like a code smell.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to derive from these classes?

I think so. The alternative would be to derive directly from AuthenticatedGitSourceProvider and provide overrides for the specific properties/methods (e.g. GitSupportsFetchingCommitBySha1Hash). That feels more likely to drift out of sync

Feels like a code smell.

Not sure what that means

{
public override bool GitSupportsFetchingCommitBySha1Hash
{
Expand All @@ -86,7 +86,7 @@ public override bool GitSupportsFetchingCommitBySha1Hash
}
}

public sealed class GitHubSourceProvider : AuthenticatedGitSourceProvider
public class GitHubSourceProvider : AuthenticatedGitSourceProvider
{
public override bool GitSupportsFetchingCommitBySha1Hash
{
Expand All @@ -97,7 +97,7 @@ public override bool GitSupportsFetchingCommitBySha1Hash
}
}

public sealed class TfsGitSourceProvider : GitSourceProvider
public class TfsGitSourceProvider : GitSourceProvider
{
public override bool GitSupportsFetchingCommitBySha1Hash
{
Expand Down Expand Up @@ -382,7 +382,7 @@ public async Task GetSourceAsync(
gitEnv[formattedKey] = variable.Value?.Value ?? string.Empty;
}

GitCliManager gitCommandManager = new GitCliManager(gitEnv);
GitCliManager gitCommandManager = GetCliManager(gitEnv);
await gitCommandManager.LoadGitExecutionInfo(executionContext, useBuiltInGit: !preferGitFromPath);

bool gitSupportAuthHeader = GitSupportUseAuthHeader(executionContext, gitCommandManager);
Expand Down Expand Up @@ -1191,7 +1191,7 @@ public async Task PostJobCleanupAsync(AgentTaskPluginExecutionContext executionC
bool preferGitFromPath = StringUtil.ConvertToBoolean(executionContext.TaskVariables.GetValueOrDefault("preferPath")?.Value);

// Initialize git command manager
GitCliManager gitCommandManager = new GitCliManager();
GitCliManager gitCommandManager = GetCliManager();
await gitCommandManager.LoadGitExecutionInfo(executionContext, useBuiltInGit: !preferGitFromPath);

executionContext.Debug("Remove any extraheader, proxy and client cert setting from git config.");
Expand Down Expand Up @@ -1219,6 +1219,11 @@ public async Task PostJobCleanupAsync(AgentTaskPluginExecutionContext executionC
}
}

protected virtual GitCliManager GetCliManager(Dictionary<string, string> gitEnv = null)
damccorm marked this conversation as resolved.
Show resolved Hide resolved
{
return new GitCliManager(gitEnv);
}

private async Task<bool> IsRepositoryOriginUrlMatch(AgentTaskPluginExecutionContext context, GitCliManager gitCommandManager, string repositoryPath, Uri expectedRepositoryOriginUrl)
{
context.Debug($"Checking if the repo on {repositoryPath} matches the expected repository origin URL. expected Url: {expectedRepositoryOriginUrl.AbsoluteUri}");
Expand Down
6 changes: 3 additions & 3 deletions src/Agent.Plugins/RepositoryPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected RepositoryTask(ISourceProviderFactory sourceProviderFactory)

public Guid Id => Pipelines.PipelineConstants.CheckoutTask.Id;

public ISourceProviderFactory SourceProviderFactory { get; }
public ISourceProviderFactory SourceProviderFactory { get; set; }
damccorm marked this conversation as resolved.
Show resolved Hide resolved

public abstract string Stage { get; }

Expand Down Expand Up @@ -214,9 +214,9 @@ public interface ISourceProviderFactory
ISourceProvider GetSourceProvider(string repositoryType);
}

public sealed class SourceProviderFactory : ISourceProviderFactory
public class SourceProviderFactory : ISourceProviderFactory
{
public ISourceProvider GetSourceProvider(string repositoryType)
public virtual ISourceProvider GetSourceProvider(string repositoryType)
damccorm marked this conversation as resolved.
Show resolved Hide resolved
{
ISourceProvider sourceProvider = null;

Expand Down
14 changes: 14 additions & 0 deletions src/Agent.Sdk/Util/StringUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,20 @@ private static string Format(CultureInfo culture, string format, params object[]
}
}

// Used for L1 testing
public static void LoadExternalLocalization(string stringsPath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personal preference would be to have a class like TestingStringUtil in the test project with this method instead of adding it to non testing code if we only need it for testing.

Having it here implies it's got production quality tests and some use outside of testing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second look we are setting some values on the util here.

This setup feels wrong to me :) It may be out of the scope of the PR but feels like it's structured incorrectly.

Maybe also this class should be split into 2? One for StringUtil and one for LocalizationStringUtil?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class might be worth revisiting in the future, but it seems out of scope here. With the current design, this seems like the best way to achieve the objective of getting some localization loaded for testing.

{
var locStrings = new Dictionary<string, object>();
if (File.Exists(stringsPath))
{
foreach (KeyValuePair<string, object> pair in IOUtil.LoadObject<Dictionary<string, object>>(stringsPath))
{
locStrings[pair.Key] = pair.Value;
}
}
s_locStrings = locStrings;
}

private static void EnsureLoaded()
{
if (s_locStrings == null)
Expand Down
4 changes: 2 additions & 2 deletions src/Agent.Worker/AgentPluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public interface IAgentPluginManager : IAgentService
Task RunPluginTaskAsync(IExecutionContext context, string plugin, Dictionary<string, string> inputs, Dictionary<string, string> environment, Variables runtimeVariables, EventHandler<ProcessDataReceivedEventArgs> outputHandler);
}

public sealed class AgentPluginManager : AgentService, IAgentPluginManager
public class AgentPluginManager : AgentService, IAgentPluginManager
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question about deriving.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure which question this is in reference to

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to derive here so that we can add/remove plugins without altering any of the rest of the execution

{
private readonly Dictionary<Guid, List<string>> _supportedTasks = new Dictionary<Guid, List<string>>();

private readonly HashSet<string> _taskPlugins = new HashSet<string>()
protected readonly HashSet<string> _taskPlugins = new HashSet<string>()
{
"Agent.Plugins.Repository.CheckoutTask, Agent.Plugins",
"Agent.Plugins.Repository.CleanupTask, Agent.Plugins",
Expand Down
6 changes: 6 additions & 0 deletions src/Agent.Worker/AsyncCommandContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public interface IAsyncCommandContext : IAgentService
void Output(string message);
void Debug(string message);
Task WaitAsync();
IHostContext GetHostContext();
}

public class AsyncCommandContext : AgentService, IAsyncCommandContext
Expand Down Expand Up @@ -50,6 +51,11 @@ public void InitializeCommandContext(IExecutionContext context, string name)
Name = name;
}

public IHostContext GetHostContext()
{
return _executionContext.GetHostContext();
}

public void Output(string message)
{
_outputQueue.Enqueue(new OutputMessage(OutputType.Info, message));
Expand Down
16 changes: 9 additions & 7 deletions src/Agent.Worker/Build/ArtifactCommandExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,9 @@ public static async Task AssociateArtifactAsync(
Dictionary<string, string> propertiesDictionary,
CancellationToken cancellationToken)
{
BuildServer buildHelper = new BuildServer(connection, projectId);
var artifact = await buildHelper.AssociateArtifactAsync(buildId, name, jobId, type, data, propertiesDictionary, cancellationToken);
var buildHelper = context.GetHostContext().GetService<IBuildServer>();
await buildHelper.ConnectAsync(connection);
var artifact = await buildHelper.AssociateArtifactAsync(buildId, projectId, name, jobId, type, data, propertiesDictionary, cancellationToken);
context.Output(StringUtil.Loc("AssociateArtifactWithBuild", artifact.Id, buildId));
}

Expand All @@ -234,15 +235,16 @@ public static async Task UploadArtifactAsync(
string source,
CancellationToken cancellationToken)
{
FileContainerServer fileContainerHelper = new FileContainerServer(connection, projectId, containerId, containerPath);
long size = await fileContainerHelper.CopyToContainerAsync(context, source, cancellationToken);
var fileContainerHelper = new FileContainerServer(connection, projectId, containerId, containerPath);
var size = await fileContainerHelper.CopyToContainerAsync(context, source, cancellationToken);
propertiesDictionary.Add(ArtifactUploadEventProperties.ArtifactSize, size.ToString());

string fileContainerFullPath = StringUtil.Format($"#/{containerId}/{containerPath}");
var fileContainerFullPath = StringUtil.Format($"#/{containerId}/{containerPath}");
context.Output(StringUtil.Loc("UploadToFileContainer", source, fileContainerFullPath));

BuildServer buildHelper = new BuildServer(connection, projectId);
var artifact = await buildHelper.AssociateArtifactAsync(buildId, name, jobId, ArtifactResourceTypes.Container, fileContainerFullPath, propertiesDictionary, cancellationToken);
var buildHelper = context.GetHostContext().GetService<IBuildServer>();
await buildHelper.ConnectAsync(connection);
var artifact = await buildHelper.AssociateArtifactAsync(buildId, projectId, name, jobId, ArtifactResourceTypes.Container, fileContainerFullPath, propertiesDictionary, cancellationToken);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question about types. I can't tell from this line the type of artifact.

context.Output(StringUtil.Loc("AssociateArtifactWithBuild", artifact.Id, buildId));
}

Expand Down
20 changes: 11 additions & 9 deletions src/Agent.Worker/Build/BuildCommandExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Microsoft.VisualStudio.Services.Agent.Worker.Build
{
public sealed class BuildCommandExtension: BaseWorkerCommandExtension
public sealed class BuildCommandExtension : BaseWorkerCommandExtension
{
public BuildCommandExtension()
{
Expand All @@ -27,7 +27,7 @@ public BuildCommandExtension()
}
}

public sealed class BuildUploadLogCommand: IWorkerCommand
public sealed class BuildUploadLogCommand : IWorkerCommand
{
public string Name => "uploadlog";
public List<string> Aliases => null;
Expand All @@ -49,7 +49,7 @@ public void Execute(IExecutionContext context, Command command)

// ##VSO[build.uploadsummary] command has been deprecated
// Leave the implementation on agent for back compat
public sealed class BuildUploadSummaryCommand: IWorkerCommand
public sealed class BuildUploadSummaryCommand : IWorkerCommand
{
public string Name => "uploadsummary";
public List<string> Aliases => null;
Expand All @@ -70,7 +70,7 @@ public void Execute(IExecutionContext context, Command command)
}
}

public sealed class BuildUpdateBuildNumberCommand: IWorkerCommand
public sealed class BuildUpdateBuildNumberCommand : IWorkerCommand
{
public string Name => "updatebuildnumber";
public List<string> Aliases => null;
Expand Down Expand Up @@ -119,13 +119,14 @@ private async Task UpdateBuildNumberAsync(
string buildNumber,
CancellationToken cancellationToken)
{
BuildServer buildServer = new BuildServer(connection, projectId);
var build = await buildServer.UpdateBuildNumber(buildId, buildNumber, cancellationToken);
var buildServer = context.GetHostContext().GetService<IBuildServer>();
await buildServer.ConnectAsync(connection);
var build = await buildServer.UpdateBuildNumber(buildId, projectId, buildNumber, cancellationToken);
context.Output(StringUtil.Loc("UpdateBuildNumberForBuild", build.BuildNumber, build.Id));
}
}

public sealed class BuildAddBuildTagCommand: IWorkerCommand
public sealed class BuildAddBuildTagCommand : IWorkerCommand
{
public string Name => "addbuildtag";
public List<string> Aliases => null;
Expand Down Expand Up @@ -170,8 +171,9 @@ private async Task AddBuildTagAsync(
string buildTag,
CancellationToken cancellationToken)
{
BuildServer buildServer = new BuildServer(connection, projectId);
var tags = await buildServer.AddBuildTag(buildId, buildTag, cancellationToken);
var buildServer = context.GetHostContext().GetService<IBuildServer>();
await buildServer.ConnectAsync(connection);
var tags = await buildServer.AddBuildTag(buildId, projectId, buildTag, cancellationToken);

if (tags == null || !tags.Any(t => t.Equals(buildTag, StringComparison.OrdinalIgnoreCase)))
{
Expand Down
Loading