【问题标题】:To run aws ECR scan commands in jenkinsfile在 jenkinsfile 中运行 aws ECR 扫描命令
【发布时间】:2023-03-11 05:55:01
【问题描述】:

尝试在 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                                    

【问题讨论】:

    标签: image scanning aws-ecr jenkins-pipeline-unit


    【解决方案1】:

    更新 AWS CLI 版本。 aws-cli/1.11.13 我也遇到了同样的问题。但在 aws-cli/1.18.16

    中得到了预期的结果

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 2021-12-08
        • 2021-08-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-10-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多