我正在尝试将此 powershell 命令传递给 aws ssm:
$CMD = "docker image inspect $(docker inspect $(docker ps --filter ancestor=.dkr.ecr.us-east-1.amazonaws.com/service:latest -q) --format '{{.Image}}') --format '{{.RepoDigests}}'"
aws ssm send-command --document-name "AWS-RunPowerShellScript" --targets "Key=tag:group,Values=value" --parameters commands="'$CMD'"
但我不断收到此错误:
aws :
At C:\jenkins\workspace\Test_Patch_Update@tmp\durable-4179e3f3\powershellScript.ps1:4 char:33
+ ... aws ssm send-command --document-name "AWS-RunPowerShellSc ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Error parsing parameter '--parameters': Expected: ',', received: '{' for input:
commands='docker image inspect $(docker inspect $(docker ps --filter ancestor=dkr.ecr.us-east-1.amazonaws.com/service:latest -q) --format '{{.Image}}')
--format '{{.RepoDigests}}''
我尝试通过将两个单引号放在一起来转义单引号,''
但它仍然显示错误:
aws :
At C:\jenkins\workspace\Test_Patch_Update@tmp\durable-521ed40a\powershellScript.ps1:4 char:33
+ ... aws ssm send-command --document-name "AWS-RunPowerShellSc ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Error parsing parameter '--parameters': Expected: ',', received: ''' for input:
commands='docker image inspect $(docker inspect $(docker ps --filter ancestor=dkr.ecr.us-east-1.amazonaws.com/service:latest -q) --format ''{{.Image}}'')
--format ''{{.RepoDigests}}'''
PS:我在詹金斯运行它