【问题标题】:How to check-in the file in TFS which is checked out for edit with its check-in requirement如何在 TFS 中签入文件,该文件已根据签入要求签出以进行编辑
【发布时间】: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


【解决方案1】:

不幸的是,对于 VS 中带有 Team Explorer 的 TFVC,“tf.exe checkin”不支持从命令行关联工作项。没有参数:/Related Work Items。 有关详细信息,请参阅Checkin command

这里还有一个问题:https://github.com/Microsoft/vsts-vscode/issues/191

但是,您可以尝试将 Team Explorer Everywhere 与以下命令一起使用 将一个或多个工作项与变更集相关联:

tf checkin ItemSpec -associate:WorkItemIds

详情请见Associate Work Items with Changesets (Team Explorer Everywhere)

还有这个帖子供您参考:Link command line tf checkin to work item

【讨论】:

  • 现在对于没有 WorkItemId 的 CheckIn,我正在使用 /override 参数,至少它允许我签入。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-06-02
  • 2011-05-27
  • 2015-05-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-05
相关资源
最近更新 更多