Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Tfs Team Foundation Server 2018 API生成定义错误_Tfs_Tfs 2015_Tfs Sdk_Azure Devops Rest Api - Fatal编程技术网

Tfs Team Foundation Server 2018 API生成定义错误

Tfs Team Foundation Server 2018 API生成定义错误,tfs,tfs-2015,tfs-sdk,azure-devops-rest-api,Tfs,Tfs 2015,Tfs Sdk,Azure Devops Rest Api,我正在尝试使用Powershell 5.1通过REST API创建新的构建定义 我的脚本由一些文件组成。 在我的脚本中,我有以下内容: 文件1: $newDefinitionUrl = "http://tfs:8080/tfs/collection/project/_apis/build/definitions?api-version={2}" -f $CollectionUrl,$TeamProjectName,$BuildApiVersion $method = "POST

我正在尝试使用Powershell 5.1通过REST API创建新的构建定义

我的脚本由一些文件组成。 在我的脚本中,我有以下内容:

文件1:

 $newDefinitionUrl = "http://tfs:8080/tfs/collection/project/_apis/build/definitions?api-version={2}" -f $CollectionUrl,$TeamProjectName,$BuildApiVersion
        $method = "POST"
        $headers = @{"Content-Type"="application/json"} 
        $body=ConvertTo-Json $template -Depth 20 -Compress  

    #[ERROR 1 - line 80] 
    Invoke-RestMethod -Credential $credentials -Uri $newDefinitionUrl -Method $method -Headers $headers -Body ([System.Text.Encoding]::UTF8.GetBytes($body)) 
文件2:

$templateName = "$bdType $systemTecnology"
$buildDefinitionName = Get-GloboBuildDefinitionName -System $System -BranchName $BranchName -Type $Type

 #[Error 2 - Line 115]
$newDef = New-BuildDefinition -CollectionUrl $Tfs.Uri.AbsoluteUri -TeamProjectName $TeamProjectName -TemplateName $templateName  -BuildDefinitionName $buildDefinitionName -TemplateTeamProjectName $TeamProjectBuildTemplate -OverwriteParameters $parameters 
文件3:

Write-Output "`t-> Criando branch para o $workitemTitle no SourceControl apartir do Release..." -OutVariable +MSGS
        New-TFVCBrach -Tfs $Tfs -SourcePath "$/$TeamProjectName/$System/$branchOrigin" -DestinationPath "$/$TeamProjectName/$System/$branchFolder/$workitemTitle" -ErrorVariable +MSGS | Out-String | Write-Verbose

        Write-Output "`t-> Concedendo permissão ao time ""[$TeamProjectName]\$System"" no branch..." -OutVariable +MSGS
        Get-Content $GloboTFSSetupTemplateFolderPath"\PermissionsFolders.txt" | Set-BranchPermisisons -CollectionUrl $CollectionUrl -TeamProjectName $TeamProjectName -System $System -BranchRelativePath "$branchFolder/$workitemTitle" -Group "[$TeamProjectName]\$System" -ErrorVariable +MSGS | Out-String | Write-Verbose

        Write-Output "`t-> Criando build definition de ""$buildType"" para o ""$WorkItemType""..." -OutVariable +MSGS

#[Error 3 - Line 99]            
New-GloboBuildDefinition -Tfs $Tfs -TeamProjectName $TeamProjectName -System $System -Type $buildType -BranchName $workitemTitle -ErrorVariable +MSGS | Out-String | Write-Verbose 
当我尝试运行脚本时,我得到了3个错误,我在这里用#[Error 1/2/3-Line x]标记了这些错误,以便于识别

以下是错误:

在我的TFS 2015中,该脚本起了作用。 但现在在2018年TFS中,我发现了这个错误

有人能帮我吗

此外,我还发现了一些错误:

Cannot index into a null array.
System.Management.Automation.CmdletInvocationException: Cannot index into a null array. ---> System.Management.Automation.RuntimeException: Cannot index into a null array. at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0) at System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(ScriptBlockClauseToInvoke clauseToInvoke, Boolean createLocalScope, Dictionary`2 functionsToDefine, List`1 variablesToDefine, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Object[] args) at System.Management.Automation.ScriptBlock.<>c__DisplayClass57_0.b__0() at System.Management.Automation.Runspaces.RunspaceBase.RunActionIfNoRunningPipelinesWithThreadCheck(Action action) at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Boolean propagateAllExceptionsToTop, List`1 variablesToDefine, Dictionary`2 functionsToDefine, Object[] args) at System.Management.Automation.ScriptBlock.InvokeUsingCmdlet(Cmdlet contextCmdlet, Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Object[] args) at Microsoft.PowerShell.Commands.InvokeExpressionCommand.ProcessRecord() at System.Management.Automation.CommandProcessor.ProcessRecord() --- End of inner exception stack trace --- at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Cannot index into a null array.
Cannot index into a null array.
System.Management.Automation.CmdletInvocationException: Cannot index into a null array. ---> System.Management.Automation.RuntimeException: Cannot index into a null array. at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0) at System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(ScriptBlockClauseToInvoke clauseToInvoke, Boolean createLocalScope, Dictionary`2 functionsToDefine, List`1 variablesToDefine, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Object[] args) at System.Management.Automation.ScriptBlock.<>c__DisplayClass57_0.b__0() at System.Management.Automation.Runspaces.RunspaceBase.RunActionIfNoRunningPipelinesWithThreadCheck(Action action) at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Boolean propagateAllExceptionsToTop, List`1 variablesToDefine, Dictionary`2 functionsToDefine, Object[] args) at System.Management.Automation.ScriptBlock.InvokeUsingCmdlet(Cmdlet contextCmdlet, Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Object[] args) at Microsoft.PowerShell.Commands.InvokeExpressionCommand.ProcessRecord() at System.Management.Automation.CommandProcessor.ProcessRecord() --- End of inner exception stack trace --- at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Cannot index into a null array.
System.Management.Automation.CmdletInvocationException: {"$id":"1","innerException":null,"message":"The collection must contain at least one element.\r\nParameter name: PathFilters","typeName":"System.ArgumentException, mscorlib","typeKey":"ArgumentException","errorCode":0,"eventId":0} ---> System.Net.WebException: The remote server returned an error: (400) Bad Request. at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request) at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord() --- End of inner exception stack trace --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input) at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext) at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
{"$id":"1","innerException":null,"message":"The collection must contain at least one element.\r\nParameter name: PathFilters","typeName":"System.ArgumentException, mscorlib","typeKey":"ArgumentException","errorCode":0,"eventId":0}
无法索引到空数组中。
System.Management.Automation.CmdletInvocationException:无法索引到空数组。-->System.Management.Automation.RuntimeException:无法索引到空数组中。在System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext,Exception Exception)中的System.Management.Automation.解释器.ActionCallInstruction`2.在System.Management.Automation.解释器.EnterTryCatchFinallyInstruction.Run(解释器框架)中运行(解释器框架)在System.Management.Automation.Translator.EnterTryCatchFinallyInstruction.Run(解释器框架)在System.Management.Automation.Translator.Translator.Run(解释器框架)在System.Management.Automation.Translator.LightLambda.RunVoid1[T0](T0 arg0)在System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(ScriptBlockClauseToInvoke clauseToInvoke,布尔createLocalScope,Dictionary`2函数定义,List`1变量定义,ErrorHandlingBehavior ErrorHandlingBehavior,Object dollarUnder,Object input,Object scriptThis,Pipe outputPipe,InvocationInfo InvocationInfo,Object[]参数)在System.Management.Automation.ScriptBlock.c__中显示System.Management.Automation.Runspaces.RunspaceBase.RunActionIfNoRunningPipelinesWithThreadCheck(操作操作操作)在System.Management.Automation.ScriptBlock.InvokeWithPipe中的Class57_0.b__u0()(Boolean useLocalScope、ErrorHandlingBehavior ErrorHandlingBehavior、Object dollarUnder、Object input、Object scriptThis、Pipe outputPipe、InvocationInfo InvocationInfo、Boolean PopulateAllExceptionsTotop、List`1 variablesToDefine、Dictionary`2 functionsToDefine、Object[]args)位于System.Management.Automation.ScriptBlock.InvokeSingCmdlet(位于System.Management.Automation.Commands()的Microsoft.PowerShell.Commands.InvokeeExpressionCommand.ProcessRecord()处的Cmdlet contextCmdlet、Boolean useLocalScope、ErrorHandlingBehavior ErrorHandlingBehavior、Object dollarUnder、Object input、Object scriptThis、Object[]args)---内部异常堆栈跟踪的结束---System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext,exception exception exception)at System.Management.Automation.解释器.ActionCallInstruction`2.在System.Management.Automation.解释器.EnterTryCatchFinallyInstruction.Run运行(解释器框架)(解释器框架)在系统、管理、自动化、解释器、EnterTryCatchFinallyInstruction.Run(解释器框架)
无法索引到空数组中。
无法索引到空数组中。
System.Management.Automation.CmdletInvocationException:无法索引到空数组。-->System.Management.Automation.RuntimeException:无法索引到空数组。位于System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext,Exception Exception)在System.Management.Automation.Transparer.ActionCallInstruction`2.在System.Management.Automation.Transparer.EnterTryCatchFinallyInstruction.Run(TransparedFrame框架)在System.Management.Automation.Transparer.EnterTryCatchFinallyInstruction.Run(TransparedFrame框架)在System.Management.Automation.Transparer.Transparer.Run(解释器帧)在System.Management.Automation.Transparer.LightLambda.RunVoid1[T0](T0 arg0)在System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(ScriptBlockClauseToInvoke clauseToInvoke,布尔createLocalScope,Dictionary`2函数定义,List`1变量定义,ErrorHandlingBehavior ErrorHandlingBehavior,Object dollarUnder,Object input,Object scriptThis,Pipe outputPipe,InvocationInfo InvocationInfo,Object[]参数)在System.Management.Automation.ScriptBlock.c__中显示System.Management.Automation.Runspaces.RunspaceBase.RunActionIfNoRunningPipelinesWithThreadCheck(操作操作操作)在System.Management.Automation.ScriptBlock.InvokeWithPipe中的Class57_0.b__u0()(Boolean useLocalScope、ErrorHandlingBehavior ErrorHandlingBehavior、Object dollarUnder、Object input、Object scriptThis、Pipe outputPipe、InvocationInfo InvocationInfo、Boolean PopulateAllExceptionsTotop、List`1 variablesToDefine、Dictionary`2 functionsToDefine、Object[]args)位于System.Management.Automation.ScriptBlock.InvokeSingCmdlet(位于System.Management.Automation.Commands()的Microsoft.PowerShell.Commands.InvokeeExpressionCommand.ProcessRecord()处的Cmdlet contextCmdlet、Boolean useLocalScope、ErrorHandlingBehavior ErrorHandlingBehavior、Object dollarUnder、Object input、Object scriptThis、Object[]args)---内部异常堆栈跟踪的结束---System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext,exception exception exception)at System.Management.Automation.解释器.ActionCallInstruction`2.在System.Management.Automation.解释器.EnterTryCatchFinallyInstruction.Run运行(解释器框架)(解释器框架)在系统、管理、自动化、解释器、EnterTryCatchFinallyInstruction.Run(解释器框架)
无法索引到空数组中。
System.Management.Automation.CmdletInvocationException:{“$id”:“1”,“innerException”:null,“message”:“集合必须至少包含一个元素。\r\n参数名称:PathFilters”,“typeName”:“System.ArgumentException,mscorlib”,“typeKey”:“ArgumentException”,“errorCode”:0,“eventId”:0}->System.Net.WebException:远程服务器
$newDefinitionUrl = "http://tfs:8080/tfs/collection/project/_apis/build/definitions?api-version={2}" -f $CollectionUrl,$TeamProjectName,$BuildApiVersion
    $method = "POST"
    $headers = @{"Content-Type"="application/json"} 
    $body=ConvertTo-Json $template -Depth 20 -Compress  

#[ERROR 1 - line 80] 
Invoke-RestMethod -Credential $credentials -Uri $newDefinitionUrl -Method $method -Headers $headers -Body $body