
Для параметризованной сборки с выбором тега образа, понадобится плагин Active Choices
Переходим в настройки Jenkins'а

Раздел "Управление плагинами"

Переходим к вкладке "Доступные" и в поиске указываем "Active Choices"

Устанавливаем его. Так же необходим плагин Amazon Web Services SDK
Создаем "New Item" — "Pipeline", указываем, что это будет параметризованной сборка, и добавляем параметр "Active Choices Reactive Parameter"

Указываем, что это "Groovy Script" и вставляем туда следующее:
import jenkins.model.*
import groovy.json.JsonSlurper
credentialsId = 'harbor_credentials'
harborRepo = 'https://harbor.artem.services/api/repositories/artem/site'
def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
com.cloudbees.plugins.credentials.common.StandardUsernameCredentials.class, Jenkins.instance, null, null ).find{
it.id == credentialsId}
def addr = "${harborRepo}/tags"
def authString = "${creds.username}:${creds.password}".getBytes().encodeBase64().toString()
def conn = addr.toURL().openConnection()
conn.setRequestProperty( "Authorization", "Basic ${authString}" )
def response_json = "${conn.content.text}"
def slurper = new JsonSlurper()
def parsed = slurper.parseText(response_json)
def tags=[]
for (tag in parsed){
tags.add(tag.name);
}
return tags
Где значение переменных, "credentialsId" — Jenkins Credentials ID с логином и паролем к Harbor'у;
"harborRepo" — полный путь к нужному репозиторию;
Тоже самое, но уже через 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:
'''
import jenkins.model.*
import groovy.json.JsonSlurper
credentialsId = 'harbor_credentials'
harborRepo = 'https://harbor.artem.services/api/repositories/artem/site'
def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
com.cloudbees.plugins.credentials.common.StandardUsernameCredentials.class, Jenkins.instance, null, null ).find{
it.id == credentialsId}
def addr = "${harborRepo}/tags"
def authString = "${creds.username}:${creds.password}".getBytes().encodeBase64().toString()
def conn = addr.toURL().openConnection()
conn.setRequestProperty( "Authorization", "Basic ${authString}" )
def response_json = "${conn.content.text}"
def slurper = new JsonSlurper()
def parsed = slurper.parseText(response_json)
def tags=[]
for (tag in parsed){
tags.add(tag.name);
}
return tags
'''
]
]
]
])
])