Skip to content

Commit 6ada588

Browse files
Add support for the optional 'source' property to the error/warning functions (#1009)
* Added the IssueSource parameter for the PowerShell SDK and the Node SDK. * Bump package versions.
1 parent 1797678 commit 6ada588

File tree

9 files changed

+37
-12
lines changed

9 files changed

+37
-12
lines changed

node/internal.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ import crypto = require('crypto');
2020
export var _knownVariableMap: { [key: string]: _KnownVariableInfo; } = {};
2121

2222
export var _vault: vm.Vault;
23+
//-----------------------------------------------------
24+
// Enums
25+
//-----------------------------------------------------
26+
export enum IssueSource {
27+
CustomerScript = 'CustomerScript',
28+
TaskInternal = 'TaskInternal'
29+
}
2330

2431
//-----------------------------------------------------
2532
// Validation Checks
@@ -282,12 +289,12 @@ export function _command(command: string, properties: any, message: string) {
282289
_writeLine(taskCmd.toString());
283290
}
284291

285-
export function _warning(message: string): void {
286-
_command('task.issue', { 'type': 'warning' }, message);
292+
export function _warning(message: string, source?: IssueSource): void {
293+
_command('task.issue', { 'type': 'warning', 'source': source }, message);
287294
}
288295

289-
export function _error(message: string): void {
290-
_command('task.issue', { 'type': 'error' }, message);
296+
export function _error(message: string, source?: IssueSource): void {
297+
_command('task.issue', { 'type': 'error', 'source': source }, message);
291298
}
292299

293300
export function _debug(message: string): void {

node/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "azure-pipelines-task-lib",
3-
"version": "4.7.0",
3+
"version": "4.8.0",
44
"description": "Azure Pipelines Task SDK",
55
"main": "./task.js",
66
"typings": "./task.d.ts",

node/task.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export enum FieldType {
4444
Url
4545
}
4646

47+
export const IssueSource = im.IssueSource;
48+
4749
/** Platforms supported by our build agent */
4850
export enum Platform {
4951
Windows,

powershell/VstsTaskSdk/LoggingCommandFunctions.ps1

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ $script:loggingCommandEscapeMappings = @( # TODO: WHAT ABOUT "="? WHAT ABOUT "%"
88
# TODO: BUG: Escape % ???
99
# TODO: Add test to verify don't need to escape "=".
1010

11+
$IssueSources = @{
12+
CustomerScript = "CustomerScript"
13+
TaskInternal = "TaskInternal"
14+
}
15+
1116
<#
1217
.SYNOPSIS
1318
See https://github.com/Microsoft/vsts-tasks/blob/master/docs/authoring/commands.md
@@ -286,7 +291,8 @@ function Write-TaskError {
286291
[string]$SourcePath,
287292
[string]$LineNumber,
288293
[string]$ColumnNumber,
289-
[switch]$AsOutput)
294+
[switch]$AsOutput,
295+
[string]$IssueSource)
290296

291297
Write-LogIssue -Type error @PSBoundParameters
292298
}
@@ -322,7 +328,8 @@ function Write-TaskWarning {
322328
[string]$SourcePath,
323329
[string]$LineNumber,
324330
[string]$ColumnNumber,
325-
[switch]$AsOutput)
331+
[switch]$AsOutput,
332+
[string]$IssueSource)
326333

327334
Write-LogIssue -Type warning @PSBoundParameters
328335
}
@@ -544,14 +551,18 @@ function Write-LogIssue {
544551
[string]$SourcePath,
545552
[string]$LineNumber,
546553
[string]$ColumnNumber,
547-
[switch]$AsOutput)
554+
[switch]$AsOutput,
555+
[AllowNull()]
556+
[ValidateSet('CustomerScript', 'TaskInternal')]
557+
[string]$IssueSource)
548558

549559
$command = Format-LoggingCommand -Area 'task' -Event 'logissue' -Data $Message -Properties @{
550560
'type' = $Type
551561
'code' = $ErrCode
552562
'sourcepath' = $SourcePath
553563
'linenumber' = $LineNumber
554564
'columnnumber' = $ColumnNumber
565+
'source' = $IssueSource
555566
}
556567
if ($AsOutput) {
557568
return $command

powershell/VstsTaskSdk/VstsTaskSdk.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
PowerShellVersion = '3.0'
1010
FunctionsToExport = '*'
1111
CmdletsToExport = ''
12-
VariablesToExport = ''
12+
VariablesToExport = 'IssueSources'
1313
AliasesToExport = ''
1414
PrivateData = @{
1515
PSData = @{

powershell/VstsTaskSdk/VstsTaskSdk.psm1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ Export-ModuleMember -Function @(
9494
'Get-ClientCertificate'
9595
)
9696

97+
Export-ModuleMember -Variable @(
98+
'IssueSources'
99+
)
100+
97101
# Override Out-Default globally.
98102
$null = New-Item -Force -Path "function:\global:Out-Default" -Value (Get-Command -CommandType Function -Name Out-Default -ListImported)
99103
New-Alias -Name Out-Default -Value "global:Out-Default" -Scope global

powershell/package-lock.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

powershell/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.17.0",
2+
"version": "0.18.0",
33
"private": true,
44
"scripts": {
55
"build": "node make.js build",

0 commit comments

Comments
 (0)