【发布时间】:2019-10-17 06:48:32
【问题描述】:
我对 TFS 还很陌生,我仍在学习如何使用它(所以希望这不仅仅是我的愚蠢疏忽)。今年夏天我在一个季节性的开发人员职位上实习,基本上我的最终目标是自动化公司网站的负载测试。我正在使用 TFS 来实现这个目标;我目前的构建现在只有两项任务:一项启动控制器和测试环境,一项停止它们。我的问题是,由于第 1 行出现“术语无法识别”错误,构建在真正开始之前就一直失败,特别是由于默认工作文件夹似乎无法识别。
以下是相关的日志文件:
2019-05-30T20:00:02.0942883Z Executing the following powershell script. (workingFolder = D:\RM_agent\_work\11\s)
2019-05-30T20:00:02.0942883Z D:\RM_agent\_work\11\s
2019-05-30T20:00:02.4999117Z ##[error]. : The term 'D:\RM_agent\_work\11\s' is not recognized as the name of a
2019-05-30T20:00:02.4999117Z ##[error]cmdlet, function, script file, or operable program. Check the spelling of the
2019-05-30T20:00:02.4999117Z ##[error]name, or if a path was included, verify that the path is correct and try again.
2019-05-30T20:00:02.4999117Z ##[error]At line:1 char:3
2019-05-30T20:00:02.4999117Z ##[error]+ . 'D:\RM_agent\_work\11\s'
2019-05-30T20:00:02.4999117Z ##[error]+ ~~~~~~~~~~~~~~~~~~~~~~~~
2019-05-30T20:00:02.4999117Z ##[error] + CategoryInfo : ObjectNotFound: (D:\RM_agent\_work\11\s:String)
2019-05-30T20:00:02.4999117Z ##[error] [], CommandNotFoundException
2019-05-30T20:00:02.4999117Z ##[error] + FullyQualifiedErrorId : CommandNotFoundException
我知道工作文件夹默认为$(Build.SourcesDirectory),所以我假设D:\RM_agent\_work\11\s 是$(Build.SourcesDirectory) 的评估结果。 RM_agent 显然是一个代理,所以/_work/11/s 应该是它存储源代码的本地路径。那怎么就认不出来了呢?
我尝试通过 tfs 手动将脚本的工作文件夹设置为存储构建的文件夹,但构建仍然失败,日志仍然显示 workingFolder = D:\RM_agent\_work\11\s。
此外,构建失败的代码行Executing the following powershell script. (workingFolder = D:\RM_agent\_work\11\s) 不在我尝试执行的脚本中,这让我感到困惑。这个脚本是从哪里来的?
(如果它不符合指南/偏离主题,我可以删除它,但如果有人可以向我指出有关 tfs 和/或负载测试的任何资源,它也会非常有帮助)
编辑:这是第一个任务的 powershell 脚本
########################################
# start environment
########################################
# import modules
Import-Module '\\neenah-san1\TSbuild\Deployment\Tools\PowerShell\Azure\JJK.TS.Azure.psm1' -Force -Prefix 'TS'
# provide azure credentials
$credential = Get-Credential
# login to azure subscription
Login-AzureRmAccount -Credential $credential
# start the controller
Get-AzureRmVM -ResourceGroupName 'TS-LoadTest-TST' | Where-Object {$_.Name -match 'vstc'} | Start-TSAzureVM -Credential $credential
# wait for controller to fully start
Start-Sleep -Seconds 120
# start the agents
Get-AzureRmVM -ResourceGroupName 'TS-LoadTest-TST' | Where-Object {$_.Name -match 'vsta'} | Start-TSAzureVM -Credential $credential
# check status of all servers
Get-AzureRmVM -ResourceGroupName 'TS-LoadTest-TST' -Status | Sort-Object -Property Name | Select-Object -Property Name, PowerState | Format-Table -AutoSize
编辑 2:[已解决] 现在一切都已修复,谢谢!我进入存储库并将我的脚本所在的文件夹直接映射到$(build.sourcesDirectory)。因此,我能够将文件路径更改为 $(build.sourcesDirectory)\StartControllerAndAgents.ps1,并且构建现在能够找到要运行的文件。
【问题讨论】:
-
你的脚本是什么样的?
-
@jessehouwing 这是 tfs 配置 [imgur] (imgur.com/a/X21Frhf) 这就是解决方案路径的样子 [imgur] (imgur.com/cFEhB9M)
标签: powershell tfs azure-pipelines