-
Notifications
You must be signed in to change notification settings - Fork 0
CI Host Azure DevOps
AzureDevOpsHost resolves automatically when TF_BUILD=True (the canonical Azure DevOps Pipelines marker). Inherits the common CiHost surface (CI Host Integrations) and adds ADO-specific properties and commands.
if (CiHost is AzureDevOpsHost ado)
{
// ADO Pipelines specifics
}| Property | Env var |
|---|---|
BuildId |
BUILD_BUILDID |
BuildNumber |
BUILD_BUILDNUMBER |
DefinitionName |
BUILD_DEFINITIONNAME |
Reason |
BUILD_REASON (Manual / IndividualCI / BatchedCI / Schedule / PullRequest) |
RepositoryName |
BUILD_REPOSITORY_NAME |
RepositoryUri |
BUILD_REPOSITORY_URI |
SourceBranch |
BUILD_SOURCEBRANCH |
SourceBranchName |
BUILD_SOURCEBRANCHNAME |
SourceVersion |
BUILD_SOURCEVERSION (commit SHA) |
SourcesDirectory |
BUILD_SOURCESDIRECTORY |
ArtifactStagingDirectory |
BUILD_ARTIFACTSTAGINGDIRECTORY |
AgentName |
AGENT_NAME |
AgentOs |
AGENT_OS |
CollectionUri |
SYSTEM_TEAMFOUNDATIONCOLLECTIONURI |
TeamProject |
SYSTEM_TEAMPROJECT |
PullRequestId |
SYSTEM_PULLREQUEST_PULLREQUESTID |
PullRequestTargetBranch |
SYSTEM_PULLREQUEST_TARGETBRANCH |
Derived helper:
ado.IsPullRequest // true when SYSTEM_PULLREQUEST_PULLREQUESTID is non-emptyado.OpenGroup("Build"); // ##[group]Build
ado.CloseGroup(); // ##[endgroup]
ado.LogWarning("careful"); // ##vso[task.logissue type=warning]careful
ado.LogError("oops"); // ##vso[task.logissue type=error]oops
ado.SetVariable("MyVar", "value"); // ##vso[task.setvariable variable=MyVar]valueLogError marks the run with the issue (visible in the build summary). Multiple errors aggregate.
ado.SetSecretVariable("Token", value); // marked as secret; ADO redacts in logs
ado.UpdateBuildNumber("1.2.3-rc.1"); // overrides the auto-assigned build number
ado.UploadArtifact("/path/to/file"); // attaches as an artifact on the runSetSecretVariable adds ;issecret=true to the task.setvariable command. Subsequent steps that reference $(Token) will receive the value, but it's redacted from logs by ADO itself.
Target ResolveBuildNumber => _ => _.Executes(() =>
{
var bn = $"1.0.0-{Git.Branch}-{Git.Commit[..7]}";
if (CiHost is AzureDevOpsHost ado) ado.UpdateBuildNumber(bn);
BuildNumber = bn;
});Target UploadArtifacts => _ => _
.DependsOn(nameof(Pack))
.Executes(() =>
{
if (CiHost is not AzureDevOpsHost ado) return;
Artifacts.GlobFiles("*.nupkg").ForEach(f => ado.UploadArtifact(f.Value));
});(For first-class artifact upload that also works in non-ADO contexts, prefer the actions/upload-artifact-equivalent in the pipeline YAML; this command is the inline fallback.)
Target ProvisionToken => _ => _.Executes(() =>
{
var token = ResolveTokenFromKeyVault(); // returns a Secret
if (CiHost is AzureDevOpsHost ado)
ado.SetSecretVariable("DownstreamToken", token.Reveal());
});Secret.Reveal is internal-only — the wrapper for that secret type, not the build script, makes the call. In a real script you'd use a wrapper that takes a Secret and emits the right commands; for now SetSecretVariable takes a string for parity with the underlying ADO command.
Start here
Modules
- Module Catalog (canonical list, 50+ satellites)
- .NET toolchain
- Containers
- JS toolchain
- Supply-chain security
Analyzers
Tooling
Execution
CI integration
Editor integration
Migration
Reference
Project