-
Notifications
You must be signed in to change notification settings - Fork 913
Description
What happened?
I'm a devops engineer, developing a custom pipeline task for azure devops pipelines. I'd like my task to tag the build with an emoji, (e.g. a cookie because the developer done good, or a warning triangle if they did bad) - but I don't seem to be able to reliably do this.
I seem to be running into this exception:
https://github.com/microsoft/azure-pipelines-agent/blob/master/src/Agent.Worker/Build/BuildCommandExtension.cs#L192
I can hit it from several paths.
- I've tried to add a tag from within my task, via azure-pipelines-task-lib/task:
import * as tl from 'azure-pipelines-task-lib/task';
tl.addBuildTag("🏷️");This looks like it has worked at first, but eventually yields and error:
##[debug]Add build tag: 🏷️ to build: 1553 at backend.
##[debug]Processed: ##vso[build.addbuildtag]🏷️
##[debug]SystemVssConnection exists true
##[debug]System.TeamFoundationCollectionUri=https://dev.azure.com/etcetera-etcetera/
##[debug]Tagging build 1553 in project xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx with tag '🏷️'
...
Async Command Start: Add Build Tag
Async Command End: Add Build Tag
##[error]Build tag '🏷️' was not added successfully.
##[debug]System.Exception: Build tag '🏷️' was not added successfully.
at Microsoft.VisualStudio.Services.Agent.Worker.Build.BuildAddBuildTagCommand.AddBuildTagAsync(IAsyncCommandContext context, VssConnection connection, Guid projectId, Int32 buildId, String buildTag, CancellationToken cancellationToken) in D:\a\_work\1\s\src\Agent.Worker\Build\BuildCommandExtension.cs:line 192
at Microsoft.VisualStudio.Services.Agent.Worker.AsyncCommandContext.WaitAsync() in D:\a\_work\1\s\src\Agent.Worker\AsyncCommandContext.cs:line 130
at Microsoft.VisualStudio.Services.Agent.Worker.StepsRunner.RunStepAsync(IStep step, CancellationToken jobCancellationToken) in D:\a\_work\1\s\src\Agent.Worker\StepsRunner.cs:line 417
- I've also tried to add a tag form within my task, via azure-devops-node-api:
import * as tl from 'azure-pipelines-task-lib/task';
import * as wa from 'azure-devops-node-api/WebApi';
import * as ba from 'azure-devops-node-api/BuildApi';
export async function tagBuild(tag: string): Promise<void> {
let buildApi: ba.IBuildApi = await getBuildApiInstance();
const projectId = tl.getVariable('System.TeamProjectId');
const buildId = parseInt(tl.getVariable('Build.BuildId'));
tl.debug(`Tagging build ${buildId} in project ${projectId} with tag '${tag}'`);
await buildApi.addBuildTag(projectId, buildId, tag);
};But this just gives me a 💎, not a 🏷️.
I see my tag in the build log's debug stream (tl.debug() above) -- and no errors, it does actually tag the build:
...
##[debug]Tagging build 1550 in project xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx with tag '🏷️'
...
But the tag I get isn't a 🏷️ ... it's a 💎:
- I've tried also inline PowerShell:
- task: PowerShell@2
displayName: "Tag 🏷️"
condition: always()
inputs:
targetType: 'inline'
script: |
Write-Host "##vso[build.addbuildtag]🏷️"
workingDirectory: '$(Build.SourcesDirectory)'This yields:
##[debug]Add build tag: 🏷️ to build: 1545 at backend.
##[debug]Processed: ##vso[build.addbuildtag]🏷️
##[debug]$LASTEXITCODE is not set.
##[debug]Exit code: 0
##[debug]Leaving Invoke-VstsTool.
##[debug]Leaving S:\a\_tasks\PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1\2.266.0\powershell.ps1.
Async Command Start: Add Build Tag
Async Command End: Add Build Tag
##[error]Build tag '🏷️' was not added successfully.
##[debug]System.Exception: Build tag '🏷️' was not added successfully.
at Microsoft.VisualStudio.Services.Agent.Worker.Build.BuildAddBuildTagCommand.AddBuildTagAsync(IAsyncCommandContext context, VssConnection connection, Guid projectId, Int32 buildId, String buildTag, CancellationToken cancellationToken) in D:\a\_work\1\s\src\Agent.Worker\Build\BuildCommandExtension.cs:line 192
at Microsoft.VisualStudio.Services.Agent.Worker.AsyncCommandContext.WaitAsync() in D:\a\_work\1\s\src\Agent.Worker\AsyncCommandContext.cs:line 130
at Microsoft.VisualStudio.Services.Agent.Worker.StepsRunner.RunStepAsync(IStep step, CancellationToken jobCancellationToken) in D:\a\_work\1\s\src\Agent.Worker\StepsRunner.cs:line 417
Finishing: Tag 🏷️
However, it works when I ask for a gemstone. Other emojis that I've tried fail:
- task: PowerShell@2
displayName: "Tag 💎"
condition: always()
inputs:
targetType: 'inline'
script: |
Write-Host "##vso[build.addbuildtag]💎"
workingDirectory: '$(Build.SourcesDirectory)'
- task: PowerShell@2
displayName: "Tag 🏷️"
condition: always()
inputs:
targetType: 'inline'
script: |
Write-Host "##vso[build.addbuildtag]🏷️"
workingDirectory: '$(Build.SourcesDirectory)'
- task: PowerShell@2
displayName: "Tag 📢"
condition: always()
inputs:
targetType: 'inline'
script: |
Write-Host "##vso[build.addbuildtag]📢"
workingDirectory: '$(Build.SourcesDirectory)'
- task: PowerShell@2
displayName: "Tag 🍪"
condition: always()
inputs:
targetType: 'inline'
script: |
Write-Host "##vso[build.addbuildtag]🍪"
workingDirectory: '$(Build.SourcesDirectory)'Yields the following outputs:
(for what it's worth, adding the 💎 works, even if I run the task last after the other three fail)
Async Command Start: Add Build Tag
Build '1546' has following tags now: 💎
Async Command End: Add Build Tag
Finishing: Tag 💎
Async Command Start: Add Build Tag
Async Command End: Add Build Tag
##[error]Build tag '🏷️' was not added successfully.
Finishing: Tag 🏷️
Async Command Start: Add Build Tag
Async Command End: Add Build Tag
##[error]Build tag '📢' was not added successfully.
Finishing: Tag 📢
Async Command Start: Add Build Tag
Async Command End: Add Build Tag
##[error]Build tag '🍪' was not added successfully.
Finishing: Tag 🍪
I do plan on using the 💎, but I'd like to use some others as well.
Versions
- Current agent version: '4.266.2'
- Windows Server 2025
Environment type (Please select at least one enviroment where you face this issue)
- Self-Hosted
- Microsoft Hosted
- VMSS Pool
- Container
Azure DevOps Server type
dev.azure.com (formerly visualstudio.com)
Azure DevOps Server Version (if applicable)
No response
Operation system
all
Version controll system
Git