2016-08-14 27 views
8

Tôi đã theo sát hướng dẫn thiết kế tìm thấy here, herehere, nhưng tôi cứ bị lỗi PowerShell này:TFS 2015,3 tùy chỉnh xây dựng bước không gửi các biến để kịch bản

Cannot process command because of one or more missing mandatory parameters: SourcePath FilePattern BuildRegex.

Các dữ liệu cấu hình có liên quan là bên dưới .

Tôi đã kiểm tra và kiểm tra kỹ để đảm bảo rằng các biến có trong tệp task.json của tôi. Tôi cũng đã xem xét cấu hình cho các tác vụ làm việc khác (ví dụ: VSBuild) và không có sự khác biệt đáng kể trong khai báo biến và cú pháp thực hiện PowerShell.

Điều gì có thể xảy ra ở đây? Đây là một kiến ​​trúc rất đơn giản - không có nhiều thứ để phá vỡ. Nhưng rõ ràng một cái gì đó đã làm được điều đó.


Từ task.json:

"inputs": [ 
    { 
    "name": "SourcePath", 
    "type": "filePath", 
    "label": "Source path", 
    "defaultValue": "", 
    "required": true, 
    "helpMarkDown": "Path in which to search for version files (like AssemblyInfo.* files). NOTE: this is case sensitive for non-Windows systems." 
    }, 
    { 
    "name": "FilePattern", 
    "type": "string", 
    "label": "File pattern", 
    "defaultValue": "AssemblyInfo.*", 
    "required": true, 
    "helpMarkDown": "File filter to replace version info. The version number pattern should exist somewhere in the file(s). Supports minimatch. NOTE: this is casese sensitive for non-Windows systems." 
    }, 
    { 
    "name": "BuildRegEx", 
    "type": "string", 
    "label": "Build RegEx pattern", 
    "defaultValue": "\\d+\\.\\d+\\.\\d+\\.\\d+", 
    "required": true, 
    "helpMarkDown": "Regular Expression to extract version from build number. This is also the default replace RegEx (unless otherwise specified in Advanced settings)." 
    }, 
    { 
    "name": "BuildRegExIndex", 
    "type": "string", 
    "label": "Build RegEx group index", 
    "defaultValue": "0", 
    "required": false, 
    "helpMarkDown": "Index of the group in the Build RegEx that you want to use as the version number. Leave as 0 if you have no groups.", 
    "groupName": "advanced" 
    }, 
    { 
    "name": "ReplaceRegEx", 
    "type": "string", 
    "label": "RegEx replace pattern", 
    "defaultValue": "", 
    "required": false, 
    "helpMarkDown": "RegEx to replace with in files. Leave blank to use the Build RegEx Pattern.", 
    "groupName": "advanced" 
    }, 
    { 
    "name": "ReplacePrefix", 
    "type": "string", 
    "label": "Prefix for replacements", 
    "defaultValue": "", 
    "required": false, 
    "helpMarkDown": "Prefix for the RegEx result string.", 
    "groupName": "advanced" 
    }, 
    { 
    "name": "ReplaceSuffix", 
    "type": "string", 
    "label": "Suffix for replacements", 
    "defaultValue": "", 
    "required": false, 
    "helpMarkDown": "Suffix for the RegEx result string.", 
    "groupName": "advanced" 
    }, 
    { 
    "name": "FailIfNoMatchFound", 
    "type": "boolean", 
    "label": "Fail if no target match found", 
    "defaultValue": "false", 
    "required": false, 
    "helpMarkDown": "Fail the build if no match is found for the replace RegEx in the target file(s).", 
    "groupName": "advanced" 
    } 
], 
"execution": { 
    "PowerShell3": { 
    "target": "VersionAssembly.ps1" 
    } 
} 

Từ VersionAssembly.ps1:

[CmdletBinding()] 
param(
    [string][Parameter(Mandatory=$True)][ValidateNotNullOrEmpty()] $SourcePath, 
    [string][Parameter(Mandatory=$True)][ValidateNotNullOrEmpty()] $FilePattern, 
    [string][Parameter(Mandatory=$True)][ValidateNotNullOrEmpty()] $BuildRegex, 
    [string]$BuildRegexIndex, 
    [string]$ReplaceRegex, 
    [string]$ReplacePrefix, 
    [string]$ReplaceSuffix, 
    [string]$FailIfNoMatchFound, 
    [string]$BuildNumber = $ENV:BUILD_BUILDNUMBER 
) 
+0

@ScottLangham: Bạn đã làm gì với phiên bản từ/đến? Xem trong tài liệu cụ thể về [Phiên bản tác vụ] (https://docs.microsoft.com/en-us/vsts/build-release/concepts/process/tasks#task-versions), trong đó nêu rõ: "* Khi trẻ vị thành niên mới Phiên bản được phát hành (ví dụ 1,2 đến 1,3), bản dựng hoặc bản phát hành của bạn sẽ tự động sử dụng phiên bản mới, tuy nhiên, nếu phiên bản chính mới được phát hành (ví dụ 2.0), bản dựng hoặc bản phát hành của bạn sẽ tiếp tục sử dụng phiên bản chính được chỉ định cho đến khi bạn chỉnh sửa định nghĩa và thay đổi theo cách thủ công sang phiên bản chính mới. * " – eggyal

+0

Tôi đã thử cả các trường nhỏ và bản vá trong phiên bản. –

+0

@ScottLangham - Tôi đã đặt các tác vụ tùy chỉnh sang một bên trong thời gian này, nhưng nếu tôi tiếp tục nỗ lực và tìm một bản sửa lỗi cho điều này, tôi sẽ gửi cho bạn. – InteXX

Trả lời

5

Rõ ràng tôi đã không theo dõi sát đủ ... Tôi đã bỏ lỡ cảnh báo trên this page:

Words of warning

Tasks can be versioned, use this to your advantage. All build definitions use the latest available version of a specific task, you can’t change this behavior from the web interface, so always assume the latest version is being used.

If you don’t change the version number of your task when updating it, the build agents that have previously used your task will not download the newer version because the version number is still the same. This means that if you change the behavior of your task, you should always update the version number!

Một khi tôi nhận được rằng tất cả thẳng ra, tất cả mọi thứ đã làm việc tốt.

2

Có thể các ví dụ chấp nhận đầu vào trong phần thông số đã lỗi thời. Có vẻ như bây giờ bạn cần sử dụng các lệnh Vsts-task-lib từ tập lệnh PowerShell của mình để nhận các tham số đầu vào.

[CmdletBinding()] 
param() 

$myParam = Get-VstsInput -Name myParam -Require 
Các vấn đề liên quan