【发布时间】:2018-05-19 01:03:16
【问题描述】:
下面是从 TFS 签出文件的代码,在签出后,更新的文件会复制到我需要签入到 TFS 的本地路径。签入时,我需要在“相关工作项”标题下的“WorkItem by ID”选项以及 cmets 和其他选项中添加值。
$TFSCheckoutExe="C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\TF.exe"
#File to be checked-out in TFS
$TFSFilePath="$/Intell/Installscript/Utility Scripts/powershells/DI_UTC_Test.PS1"
#This file needs to be checked-in in TFS after some changes are done.
$Localfilepath="C:\Intell\Installscript\Utility Scripts\powershells\DI_UTC_Test.PS1"
$demo="C:\demo\files to check in"
#Checking out file
&$TFSCheckoutExe checkout $TFSFilePath | Out-Null
#Copying the updated file to the mapped path of the file checked out.
Copy-Item -path $demo -Destination "$Localfilepath" -Force
#How to Checkin the copied file in TFS
$ItemPath = "C:\Intell\Installscript\Utility Scripts\powershells\DI_UTC_Test.PS1"
#Checkin the file by passing the required details which are require for checkin in any file.
$null = & $TFSCheckoutExe checkin $Itempath /comment:"Added POC file" /notes:"Code reviewer=None ; Unit Testing=N/A ; Build Details=N/A" /Related Work Items:"Add Work Item by ID=86165"
上面的代码在“/Related Work Items:”Add Work Item by ID=81165”的最后一行给出错误,我想在签入时添加,这只是 PBI 编号。
以下是执行脚本时出现的错误:
TF.exe : TF10139: The following check-in policies have not been satisfied:
At C:\Demo\powershell scripts\demo1.ps1:17 char:9
+ $null = & $TFSCheckoutExe checkin $Itempath /comment:"Added POC file" /notes:"Co ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (TF10139: The fo...been satisfied::String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
You must associate this check-in with one or more work items.
【问题讨论】:
-
相关工作项不是需要一个 ID 列表吗?为什么要在其中传递文本字符串“按 ID 添加工作项 =”?
-
否,在签入时,我需要填写一些必需的详细信息,然后才能将任何内容签入 TFS。例如 - 代码审查员姓名、单元测试等。就像那样,我想输入 PBI 编号。我们在相关工作项下填写:当我们手动签入时,通过单击按 ID 添加工作项选项标题,但在这里我想通过脚本传递值。
标签: powershell tfs