|
40 | 40 | echo "Preparing DOCKER_CONFIG and login to registries" |
41 | 41 | mkdir -p "${workdir}/docker" |
42 | 42 | export DOCKER_CONFIG="${workdir}/docker" |
| 43 | + echo "Logging as ${PROD_REGISTRY_USER} to ${PROD_REGISTRY}" |
43 | 44 | echo ${PROD_REGISTRY_PASSWORD} | docker login --username="${PROD_REGISTRY_USER}" --password-stdin ${PROD_REGISTRY} |
| 45 | + echo "Logging as ${DEV_REGISTRY_USER} to ${DEV_REGISTRY}" |
44 | 46 | echo ${DEV_REGISTRY_PASSWORD} | docker login --username="${DEV_REGISTRY_USER}" --password-stdin ${DEV_REGISTRY} |
45 | 47 | echo |
46 | 48 | echo "=======================================================" |
|
69 | 71 | DEV_REGISTRY_MODULE_BASEDIR="${DEV_REGISTRY}/${MODULE_DEV_REGISTRY_CUSTOM_PATH:-sys/deckhouse-oss/modules}" |
70 | 72 | severity="${SEVERITY:-UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL}" |
71 | 73 | latest_releases_amount="${LATEST_RELEASES_AMOUNT:-3}" |
| 74 | +
|
| 75 | + echo "using prod registry module base dir: ${PROD_REGISTRY_MODULE_BASEDIR}" |
| 76 | + echo "using dev registry module base dir: ${DEV_REGISTRY_MODULE_BASEDIR}" |
| 77 | + echo "using severity: ${severity}" |
| 78 | + echo "using latest releases amount: ${latest_releases_amount}" |
| 79 | +
|
72 | 80 | # If input var TAG is empty - set to default branch |
73 | 81 | if [ -z "${TAG}" ]; then |
| 82 | + echo "TAG is empty, setting to default branch: ${CI_DEFAULT_BRANCH}" |
74 | 83 | TAG="${CI_DEFAULT_BRANCH}" |
75 | 84 | fi |
76 | 85 | # prepare TAG if it was triggered with CI_COMMIT_TAG |
77 | 86 | if [ -n "${CI_COMMIT_TAG}" ]; then |
78 | 87 | TAG=$(echo "${TAG}"| sed 's/^v//' | cut -d '.' -f -2) |
| 88 | + echo "scanning from tag: ${TAG}" |
79 | 89 | fi |
80 | 90 | module_tags=("${TAG}") |
81 | 91 |
|
82 | 92 | if [ "${CI_PIPELINE_SOURCE}" == "schedule" ]; then |
| 93 | + echo "pipeline is scheduled, several latest releases will be scanned" |
83 | 94 | SCAN_SEVERAL_LASTEST_RELEASES="true" |
84 | 95 | fi |
85 | 96 | echo "Getting tags to scan" |
86 | 97 | # Check if provided tag is a semver minor, and if so - get image from prod registry |
87 | 98 | if echo "${TAG}" | grep -qE "[0-9]+\.[0-9]+"; then |
| 99 | + echo "TAG is a semver minor, getting image from prod registry" |
| 100 | + echo "total images for module found: $(crane ls "${PROD_REGISTRY_MODULE_BASEDIR}/${MODULE_NAME}" | wc -l)" |
| 101 | +
|
88 | 102 | module_tags=($(crane ls "${PROD_REGISTRY_MODULE_BASEDIR}/${MODULE_NAME}" | grep "^v${TAG}\.[0-9]*" | sort -V -r | head -n 1)) |
| 103 | + echo "selected images: ${module_tags[@]}" |
89 | 104 | fi |
90 | 105 | if [ "${SCAN_SEVERAL_LASTEST_RELEASES}" == "true" ]; then |
| 106 | + echo "scanning several latest releases" |
| 107 | +
|
91 | 108 | # Get release tags by regexp, sort by sevmer desc, cut to get minor version, uniq and get several latest |
92 | 109 | releases=($(crane ls "${PROD_REGISTRY_MODULE_BASEDIR}/${MODULE_NAME}" | grep "^v[0-9]*\.[0-9]*\.[0-9]*" | sort -V -r)) |
93 | 110 | latest_minor_releases=($(printf '%s\n' "${releases[@]}"| cut -d "." -f -2 | uniq | head -n ${latest_releases_amount})) |
| 111 | + echo "this minor releases will be scanned: ${latest_minor_releases[@]}" |
94 | 112 | for r in "${latest_minor_releases[@]}"; do |
95 | 113 | module_tags+=($(printf '%s\n' "${releases[@]}" | grep "${r}" | sort -V -r|head -n 1)) |
96 | 114 | done |
|
0 commit comments