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]+''