0

I wanted to create a jenkins pipeline that scans all the docker images in ecr..I have used the list-images command to list all the images and extracted ImageDigests in a ArrayList(arr). But it wouldn't read the value of imageDigest when interpolating it in the sh image-scan command.

    arr.each{x  ->
       sh  '''aws ecr start-image-scan --repository-name databricks --image-id imageDigest="${x}" --region us-east-1   '''                                    
    }

output : aws ecr start-image-scan --repository-name databricks --image-id imageDigest= --region us-east-1

An error occurred (InvalidParameterException) when calling the StartImageScan operation: Invalid parameter at 'imageDigest' failed to satisfy constraint: 'must satisfy regular expression '[a-zA-Z0-9-_+.]+:[a-fA-F0-9]+''

4
  • What is the value of ${x}? This command works perfectly for me. aws ecr start-image-scan --repository-name my-repo --image-id imageDigest=sha256:blahblah --profile my-profile Commented Aug 16, 2022 at 8:05
  • I had created a ArrayList of all the imageDigests I got from list-image command. x is the value of imageDigest while iterating through the ArrayList Commented Aug 16, 2022 at 11:27
  • I understood that is a array, but your command seem fine for me. Paste the command replacing the x variable for its value. You can truncate or change it but keep the format for an assessment Commented Aug 16, 2022 at 16:26
  • Actually I wanted to scan for each image in this array, as there are multiple images I want to scan..is that possible in a loop? Commented Aug 17, 2022 at 10:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.