Для параметризованной сборки с выбором тега образа, понадобится плагин Active Choices
Переходим в настройки Jenkins‘а
Раздел «Управление плагинами»
Переходим к вкладке «Доступные» и в поиске указываем «Active Choice»
Устанавливаем его.
Создаем «New Item» — «Pipeline«, указываем, что это будет параметризованной сборка, и добавляем параметр «Active Choices Reactive Parameter»
Указываем, что это «Groovy 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()
Где, «/var/lib/jenkins/.local/bin/aws» — полный путь к AWS Cli;
«eu-west-1» — регион, в котором находится ECR репозиторий;
«artem-services» — имя вашего ECR репозитория;
Тоже самое, но уже через 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() ''' ] ] ] ]) ])