Ich denke zumindest, dass die von jessehouwing beschriebene Funktion enthalten sein sollte. Ich habe dafür benutzerdefinierte Aufgaben erstellt, ich muss hoffen, dass es einen Plan gibt, aber MS hat nicht genug Zeit, um dies zu beheben. Quelle für inkludierte Aufgaben finden Sie unter: https://github.com/Microsoft/vsts-tasks/tree/master/Tasks
Dies ist eine gute Referenz Artikel: http://www.colinsalmcorner.com/post/developing-a-custom-build-vnext-task-part-1
ich die CmdLine Quelle nahm und modifiziert es eine Wenn Bedingung Eigenschaft enthalten. Ich erstellte eine Buildvariable mit dem Standardwert false und aktivierte die Option Erlauben an der Warteschlangenzeit. Anschließend wurde die Variable in die If-Bedingung-Eigenschaft der Aufgabe platziert. I modifiziert, um die Power Script:
If ($ifCondition -eq "true" -Or $ifCondition -eq "True" -Or $ifCondition -eq 1 -Or $ifCondition -eq -1)
{
Write-Host "Creating process"
...
}
Wenn ich eine build Warteschlange, wenn ich die Variable ändern 1, -1, true oder True der Prozess ausführt; Anderswize es nicht.
task.json
{
"id": "3A056A74-E34F-4767-8DCD-3F9461F4BCEC",<<<---BE SURE TO CHANGE THIS
"name": "CmdLineEx",
"friendlyName": "Command Line Ex (Conditional)",
"description": "Run a command line with arguments",
"helpMarkDown": "[More Information](http://go.microsoft.com/fwlink/?LinkID=613735)",
"category": "Utility",
"visibility": [
"Build",
"Release"
],
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 0,
"Patch": 22
},
"groups": [
{
"name": "advanced",
"displayName": "Advanced",
"isExpanded": false
}
],
"inputs": [
{
"name": "filename",
"type": "string",
"label": "Tool",
"defaultValue": "",
"required": true,
"helpMarkDown": "Tool name to run. Tool should be found in your path. Optionally, a fully qualified path can be supplied but that relies on that being present on the agent.<br/> Note: You can use **$(Build.SourcesDirectory)**\\\\ if you want the path relative to repo."
},
{
"name": "arguments",
"type": "string",
"label": "Arguments",
"defaultValue": "",
"helpMarkDown": "Arguments passed to the tool",
"required": false
},
{
"name": "ifCondition",
"type": "string",
"label": "If Condition",
"defaultValue": "",
"helpMarkDown": "Performs task if this property is set (true, True, 1, -1).",
"required": false
},
{
"name": "workingFolder",
"type": "filePath",
"label": "Working folder",
"defaultValue": "",
"required": false,
"groupName": "advanced"
},
{
"name": "failOnStandardError",
"type": "boolean",
"label": "Fail on Standard Error",
"defaultValue": "false",
"required": false,
"helpMarkDown": "If this is true, this task will fail if any errors are written to the StandardError stream.",
"groupName": "advanced"
}
],
"instanceNameFormat": "Run $(filename)",
"execution": {
"Node": {
"target": "task.js",
"argumentFormat": ""
},
"PowerShell": {
"target": "$(currentDirectory)\\task.ps1",
"argumentFormat": "",
"workingDirectory": "$(currentDirectory)"
}
},
"messages": {
"CmdLineReturnCode": "%s exited with return code: %d",
"CmdLineFailed": "%s failed with error: %s"
}
}
task.ps1
param (
[string]$filename,
[string]$arguments,
[string]$ifCondition,
[string]$workingFolder,
[string]$failOnStandardError
)
Write-Host "filename = $filename"
Write-Host "arguments = $arguments"
Write-Host "ifCondition = $ifCondition"
Write-Host "workingFolder = $workingFolder"
Write-Host "failOnStandardError = $failOnStandardError"
#########################################################################
If ($ifCondition -eq "true" -Or $ifCondition -eq "True" -Or $ifCondition -eq 1 -Or $ifCondition -eq -1)
{
Write-Host "Creating process"
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = $filename
$pinfo.RedirectStandardError = $true
$pinfo.RedirectStandardOutput = $true
$pinfo.UseShellExecute = $false
$pinfo.Arguments = $arguments
$p = New-Object System.Diagnostics.Process
$p.StartInfo = $pinfo
$p.StartInfo.WorkingDirectory = $workingFolder
Write-Host "Executing process..."
$p.Start() | Out-Null
$stdout = $p.StandardOutput.ReadToEnd()
$stderr = $p.StandardError.ReadToEnd()
$p.WaitForExit(300 * 1000)
Write-Host "Executing process complete"
Write-Host $stdout
Write-Host -Message ("Exit code : {0}" -f $p.ExitCode) -Verbose
if ($p.ExitCode -eq 1)
{
Write-Error -Message ("Stderr : {0}" -f $stderr)
}
}
#########################################################################
upload.bat
tfx build tasks upload --task-path ./ --overwrite
pause
Wieder auf ein Minimum, I t hink das Feature beschrieben jessehouwing sollte enthalten sein.
Ich würde gerne wissen, welche Art von vor/nach Schritten Sie sprechen. Es klingt wie etwas, das nicht wirklich in einem Build getan werden sollte ... – jessehouwing
als Teil der Prüfungsanforderungen, möchte ich die Quelle archivieren und einige Berichte über Abhängigkeiten laufen lassen, das sind meine Geschäftsmandate, und ich möchte nicht, dass Benutzer dies überspringen . – Anbu
Da ein Build mit einem bestimmten checkin/commit verknüpft ist, wäre es nicht einfacher, diese zusätzlichen Dinge asynchron zu generieren, nachdem der Build abgeschlossen ist? – jessehouwing