0

尝试在 Jenkins 文件中运行以下 2 个命令注意:以下命令在安装 Jenkins 的本地运行良好

sh '''  aws ecr start-image-scan --registry-id 123 \
           --repository-name test1 \
           --image-id imageTag=${BUILD_NUMBER} --output json | tee ecr_start_scan_${BUILD_NUMBER}.txt'''


sh ''' aws ecr describe-image-scan-findings --registry-id 123 \
          --repository-name test \
          --image-id imageTag=${BUILD_NUMBER}  --output json | tee ecr_scanResult_${BUILD_NUMBER}.txt'''

以下是这两个命令的输出:

+ aws ecr start-image-scan --repository-name valhalla --image-id imageTag=13 --region ap-southeast-1 --output json
+ tee ecr_start_scan_13.txt
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help
aws: error: argument operation: Invalid choice, valid choices are:

batch-check-layer-availability           | batch-delete-image                      
batch-get-image                          | complete-layer-upload                   
create-repository                        | delete-lifecycle-policy                 
delete-repository                        | delete-repository-policy                
describe-images                          | describe-repositories                   
get-authorization-token                  | get-download-url-for-layer              
get-lifecycle-policy                     | get-lifecycle-policy-preview            
get-repository-policy                    | initiate-layer-upload                   
list-images                              | put-image                               
put-lifecycle-policy                     | set-repository-policy                   
start-lifecycle-policy-preview           | upload-layer-part                       
get-login                                | help                                    
4

2 回答 2

0

更新 AWS CLI 版本。我对aws-cli/1.11.13有同样的问题。但是在aws-cli/1.18.16中得到了预期的结果

于 2020-05-06T06:11:29.447 回答
0

是的,更新 AWS CLI 版本可以解决问题,但我认为中间缺少一个步骤,aws ecr wait image-scan-complete因为扫描结果不会立即显示,因此此命令会等待结果可访问。

于 2021-05-13T18:44:54.517 回答