繁体   English   中英

无法在TFS Post构建脚本中执行AWS Powershell工具cmdlet

[英]Not able to execute AWS Powershell tool cmdlet in TFS Post build script

我试图在使用TFS构建的后期构建脚本中执行几个aws cmdlet命令。 我在构建控制器中安装了AWS SDK工具。 我可以在Build controller中手动运行相同的命令。 但是当我在TFS post build脚本中调用这些命令时。 它给我一个错误,它无法找到安装在构建控制器上的cmdlet。 我试图改变执行政策,但没有帮助。 我有一个执行政策 - 现在绕过。 脚本正在执行但只有命令无法执行。 我认为这是因为执行政策之类的问题。 当我们从power shell调用任何第三方cmdlet时,是否需要检查其他任何相同的执行策略。

命令:

Set-AWSCredentials -AccessKey  -SecretKey 

Set-DefaultAWSRegion -Region us-east-1

Write-S3Object -BucketName agero-source-package -File "\\b tfadfa\adfa\adf\asdf\adsf\asdf\asd\xyz.zip"

错误:

Set-DefaultAWSRegion : The term 'Set-DefaultAWSRegion' is not recognized as the name of a cmdlet, function, script
 file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
 and try again.
 At \\b-tfsbc001wv\c$\MV\BuildETA-API.ps1:41 char:26
 + cd "\\b-tfsbc001wv\C$" | Set-DefaultAWSRegion -Region us-east-1
 +                          ~~~~~~~~~~~~~~~~~~~~
 + CategoryInfo          : ObjectNotFound: (Set-DefaultAWSRegion:String) [], CommandNotFoundException
 + FullyQualifiedErrorId : CommandNotFoundException

 Write-S3Object : The term 'Write-S3Object' is not recognized as the name of a cmdlet, function, script file, or
 operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
 again.
 At \\b-tfsbc001wv\c$\MV\BuildETA-API.ps1:43 char:26
 + cd "\\b-tfsbc001wv\c$" | Write-S3Object -BucketName agero-source-package -File " ...
 +                          ~~~~~~~~~~~~~~
 + CategoryInfo          : ObjectNotFound: (Write-S3Object:String) [], CommandNotFoundException
 + FullyQualifiedErrorId : CommandNotFoundException

从错误消息中可以看出,无法通过运行TFS构建过程的任何帐户找到/自动加载AWSPowerShell模块。

检查模块是否已安装到全局可用位置,在该位置下,您搜索模块的PowerShell版本,或者模块文件夹的路径存在于TFS构建帐户的$ PSModulePath环境变量中。

我收到此错误,直到我使用“以管理员身份运行”运行Powershell。 所以问题可能在于权限。

我在TFS Build Agent上遇到了同样的错误:

Set-DefaultAWSRegion:术语“Set-DefaultAWSRegion”未被识别为cmdlet,函数,脚本文件或可操作程序的名称。 检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试。

安装AWS命令行界面 x64位(AWSCLI64)后,我可以通过单步执行代码行来设置Set-DefaultAWSRegion

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM