For a parameterized assembly with an image tag selection, you will need the Active Choices plugin
Go to "Manage Jenkins"
Section "Manage Plugins"
Go to the "Available" tab and select "Active Choices" in the search.
Install it.
Create a "New Item" – "Pipeline", indicate that it will be a parameterized assembly, and add the parameter "Active Choices Reactive Parameter"
We indicate that this is "Groovy Script" and paste the following into it:
def command = ['/bin/sh', '-c', '/var/lib/jenkins/.local/bin/aws ecr describe-images --region eu-west-1 --repository-name artem-services --query "sort_by(imageDetails,& imagePushedAt)[ * ].imageTags[ * ]" --output text'] def proc = command.execute() return proc.text.readLines()
Where, "/var/lib/jenkins/.local/bin/aws" – is the full path to AWS Cli;
"eu-west-1" – region where the ECR repository is located;
"artem-services" – The name of your ECR repository;
The same thing, but already in Pipeline
Pipeline:
properties([ parameters([ [$class: 'CascadeChoiceParameter', choiceType: 'PT_SINGLE_SELECT', description: 'Select Image', filterLength: 1, filterable: false, name: 'ImageTag', script: [ $class: 'GroovyScript', script: [ classpath: [], sandbox: false, script: ''' def command = ['/bin/sh', '-c', '/var/lib/jenkins/.local/bin/aws ecr describe-images --region eu-west-1 --repository-name artem-services --query "sort_by(imageDetails,& imagePushedAt)[ * ].imageTags[ * ]" --output text'] def proc = command.execute() return proc.text.readLines() ''' ] ] ] ]) ])