From 98e4ba1eaed9fd652549f48683c20162ab82ae23 Mon Sep 17 00:00:00 2001 From: Dmitry Ovcharenko Date: Sun, 29 Sep 2024 11:20:53 +0300 Subject: [PATCH 1/7] add Coverage41C --- .onec.env.example | 1 + README.md | 8 ++++++-- build-base-k8s-jenkins-agent.sh | 19 +++++++++++++++++++ build-base-swarm-jenkins-agent.bat | 21 ++++++++++++++++++++- build-base-swarm-jenkins-agent.sh | 19 +++++++++++++++++++ coverage41C/Dockerfile | 25 +++++++++++++++++++++++++ 6 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 coverage41C/Dockerfile diff --git a/.onec.env.example b/.onec.env.example index 7fa2541..8aa71db 100644 --- a/.onec.env.example +++ b/.onec.env.example @@ -2,6 +2,7 @@ export ONEC_USERNAME=onec export ONEC_PASSWORD=onec export ONEC_VERSION=8.3.18.1520 export EDT_VERSION=2021.2.7 +export COVERAGE41C_VERSION='' export DOCKER_REGISTRY_URL=docker-registry:5000 export DOCKER_LOGIN=login diff --git a/README.md b/README.md index 765e9f8..ba8a254 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ - [oscript](#oscript) - [vanessa-runner](#vanessa-runner) - [EDT](#edt) - + # Использование В терминале введите: @@ -47,6 +47,8 @@ copy .onec.env.bat.example env.bat * ONEC_PASSWORD - пароль для учётной записи на http://releases.1c.ru * ONEC_VERSION - версия платформы 1С:Преприятия 8.3, которая будет в образе * DOCKER_REGISTRY_URL - Адрес Docker-registry в котором будут храниться образы +* COVERAGE41C_VERSION - версия Coverage41C +Если заполнено, то при выполнении скриптов `build-base-*-agent.*` будут также собраны образы `base-*-coverage-agent`. В них будет установлена Coverage41C указанной версии, а также добавлены *.jar-файлы EDT для сбора замеров покрытия. Затем экспортируйте все необходимые переменные: @@ -68,7 +70,9 @@ env.bat * build-base-swarm-jenkins-agent.sh * build-edt-swarm-agent.sh * build-oscript-swarm-agent.sh + 2. Если же вы планируете использовать k8s + * build-base-k8s-jenkins-agent.sh * build-edt-k8s-agent.sh * build-oscript-k8s-agent.sh @@ -81,7 +85,7 @@ env.bat - взять ваш файл nethasp.ini - создать из него docker config командой `docker config create nethasp.ini ./nethasp.ini` -- в Jenkins, в настройках Docker Agent templates у соответствующих агентов в параметре Configs указать `nethasp.ini:/opt/1cv8/current/conf/nethasp.ini` +- в Jenkins, в настройках Docker Agent templates у соответствующих агентов в параметре Configs указать `nethasp.ini:/opt/1cv8/current/conf/nethasp.ini` ## Сервер [(Наверх)](#Оглавление) diff --git a/build-base-k8s-jenkins-agent.sh b/build-base-k8s-jenkins-agent.sh index 9a8c876..28b3480 100755 --- a/build-base-k8s-jenkins-agent.sh +++ b/build-base-k8s-jenkins-agent.sh @@ -19,6 +19,11 @@ if [ "${NO_CACHE}" = 'true' ] ; then last_arg='--no-cache .' fi +# если устанавливаем Coverage41C, то предварительно нужно собрать образы EDT +if [[ $COVERAGE41C_VERSION != "" ]] ; then + ./build-edt-swarm-agent.sh +fi + docker build \ --pull \ $no_cache_arg \ @@ -88,3 +93,17 @@ docker build \ $last_arg docker push $DOCKER_REGISTRY_URL/base-jenkins-agent:$ONEC_VERSION + +if [[ $COVERAGE41C_VERSION != "" ]] ; then + docker build \ + --build-arg DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL \ + --build-arg BASE_IMAGE=base-jenkins-agent \ + --build-arg BASE_TAG=$ONEC_VERSION \ + --build-arg EDT_VERSION=$EDT_VERSION \ + --build-arg COVERAGE41C_VERSION=$COVERAGE41C_VERSION \ + -t $DOCKER_REGISTRY_URL/base-jenkins-coverage-agent:$ONEC_VERSION \ + -f coverage41C/Dockerfile \ + $last_arg + + docker push $DOCKER_REGISTRY_URL/base-jenkins-coverage-agent:$ONEC_VERSION +fi diff --git a/build-base-swarm-jenkins-agent.bat b/build-base-swarm-jenkins-agent.bat index b010bc2..5142751 100644 --- a/build-base-swarm-jenkins-agent.bat +++ b/build-base-swarm-jenkins-agent.bat @@ -10,6 +10,8 @@ if %ERRORLEVEL% neq 0 goto end if %NO_CACHE%=="true" (SET last_arg="--no-cache .") else (SET last_arg=".") +# если устанавливаем Coverage41C, то предварительно нужно собрать образы EDT +if %COVERAGE41C_VERSION% neq "" (.\build-edt-swarm-agent.bat) docker build ^ --pull ^ @@ -99,5 +101,22 @@ docker push %DOCKER_REGISTRY_URL%/base-jenkins-agent:%ONEC_VERSION% if %ERRORLEVEL% neq 0 goto end +if %COVERAGE41C_VERSION% neq "" ( + + docker build ^ + --build-arg DOCKER_REGISTRY_URL=%DOCKER_REGISTRY_URL% ^ + --build-arg BASE_IMAGE=base-jenkins-agent ^ + --build-arg BASE_TAG=%ONEC_VERSION% ^ + --build-arg EDT_VERSION=%EDT_VERSION% ^ + --build-arg COVERAGE41C_VERSION=%COVERAGE41C_VERSION% ^ + -t %DOCKER_REGISTRY_URL%/base-jenkins-coverage-agent:%ONEC_VERSION% ^ + -f coverage41C/Dockerfile ^ + %last_arg% + + +docker push %DOCKER_REGISTRY_URL%/base-jenkins-coverage-agent:%ONEC_VERSION% + +) + :end -echo End of program. \ No newline at end of file +echo End of program. diff --git a/build-base-swarm-jenkins-agent.sh b/build-base-swarm-jenkins-agent.sh index 5517ddc..ad715e3 100755 --- a/build-base-swarm-jenkins-agent.sh +++ b/build-base-swarm-jenkins-agent.sh @@ -19,6 +19,11 @@ if [ "${NO_CACHE}" = 'true' ] ; then last_arg='--no-cache .' fi +# если устанавливаем Coverage41C, то предварительно нужно собрать образы EDT +if [[ $COVERAGE41C_VERSION != "" ]] ; then + ./build-edt-swarm-agent.sh +fi + docker build \ --pull \ $no_cache_arg \ @@ -88,3 +93,17 @@ docker build \ $last_arg docker push $DOCKER_REGISTRY_URL/base-jenkins-agent:$ONEC_VERSION + +if [[ $COVERAGE41C_VERSION != "" ]] ; then + docker build \ + --build-arg DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL \ + --build-arg BASE_IMAGE=base-jenkins-agent \ + --build-arg BASE_TAG=$ONEC_VERSION \ + --build-arg EDT_VERSION=$EDT_VERSION \ + --build-arg COVERAGE41C_VERSION=$COVERAGE41C_VERSION \ + -t $DOCKER_REGISTRY_URL/base-jenkins-coverage-agent:$ONEC_VERSION \ + -f coverage41C/Dockerfile \ + $last_arg + + docker push $DOCKER_REGISTRY_URL/base-jenkins-coverage-agent:$ONEC_VERSION +fi diff --git a/coverage41C/Dockerfile b/coverage41C/Dockerfile new file mode 100644 index 0000000..5994eb3 --- /dev/null +++ b/coverage41C/Dockerfile @@ -0,0 +1,25 @@ +ARG DOCKER_REGISTRY_URL=library +ARG BASE_IMAGE=edt +ARG BASE_TAG +ARG EDT_VERSION=2021.3 +ARG COVERAGE41C_VERSION=2.7.2 +ARG EDT_PLUGINS=/opt/1C/1CE/components/1c-edt-${EDT_VERSION}*-x86_64/plugins + +FROM ${DOCKER_REGISTRY_URL}/edt:${EDT_VERSION} as base + +FROM ${DOCKER_REGISTRY_URL}/${BASE_IMAGE}:${BASE_TAG} +LABEL maintainer="Dima Ovcharenko , Korus Consulting LLC" + +ARG COVERAGE41C_VERSION +ARG EDT_PLUGINS + +COPY --from=base ${EDT_PLUGINS}/com._1c.g5.v8.dt.debug.core_*.jar ${EDT_PLUGINS}/com._1c.g5.v8.dt.debug.model_*.jar /opt/1C/1CE/ + +ADD https://github.com/1c-syntax/Coverage41C/releases/download/v${COVERAGE41C_VERSION}/Coverage41C-${COVERAGE41C_VERSION}.tar \ + /opt/ + +RUN tar xf /opt/Coverage41C-${COVERAGE41C_VERSION}.tar -C /opt/ \ + && rm -rf /opt/Coverage41C-${COVERAGE41C_VERSION}.tar + +ENV EDT_LOCATION="/opt/1C/1CE/" +ENV PATH="/opt/Coverage41C-${COVERAGE41C_VERSION}/bin:$PATH" From bab86993a67ec85d412b51e6714f2191b1f085a9 Mon Sep 17 00:00:00 2001 From: Dmitry Ovcharenko Date: Sun, 29 Sep 2024 11:47:40 +0300 Subject: [PATCH 2/7] upd README --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ba8a254..18aa32d 100644 --- a/README.md +++ b/README.md @@ -46,9 +46,10 @@ copy .onec.env.bat.example env.bat * ONEC_USERNAME - учётная запись на http://releases.1c.ru * ONEC_PASSWORD - пароль для учётной записи на http://releases.1c.ru * ONEC_VERSION - версия платформы 1С:Преприятия 8.3, которая будет в образе +* EDT_VERSION - версия EDT. Обязательно заполнять только при сборке образов с EDT или при использовании замеров покрытия (см. `COVERAGE41C_VERSION`) * DOCKER_REGISTRY_URL - Адрес Docker-registry в котором будут храниться образы * COVERAGE41C_VERSION - версия Coverage41C -Если заполнено, то при выполнении скриптов `build-base-*-agent.*` будут также собраны образы `base-*-coverage-agent`. В них будет установлена Coverage41C указанной версии, а также добавлены *.jar-файлы EDT для сбора замеров покрытия. +Если заполнено, то при выполнении скриптов `build-base-*-agent.*` будет также собран образ `base-jenkins-coverage-agent`, подготовленный для сбора замеров покрытия с помощью Coverage41C. Требуется также указать значение для переменной EDT_VERSION. Затем экспортируйте все необходимые переменные: From 77f110cbb617fe20011219ad95097fb2e4087960 Mon Sep 17 00:00:00 2001 From: Dmitry Ovcharenko Date: Sun, 10 Nov 2024 14:42:31 +0300 Subject: [PATCH 3/7] fix script name --- build-base-k8s-jenkins-agent.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-base-k8s-jenkins-agent.sh b/build-base-k8s-jenkins-agent.sh index 28b3480..1ded1ad 100755 --- a/build-base-k8s-jenkins-agent.sh +++ b/build-base-k8s-jenkins-agent.sh @@ -21,7 +21,7 @@ fi # если устанавливаем Coverage41C, то предварительно нужно собрать образы EDT if [[ $COVERAGE41C_VERSION != "" ]] ; then - ./build-edt-swarm-agent.sh + ./build-edt-k8s-agent.sh fi docker build \ From d016935dea0f8f8d559d515b4a15c109bcbc0842 Mon Sep 17 00:00:00 2001 From: Dmitry Ovcharenko Date: Thu, 14 Nov 2024 10:52:29 +0300 Subject: [PATCH 4/7] refactoring --- README.md | 9 ++-- build-base-k8s-jenkins-agent.sh | 21 +------- build-base-k8s-jenkins-coverage-agent.sh | 35 +++++++++++++ build-base-swarm-jenkins-agent.bat | 24 ++------- build-base-swarm-jenkins-agent.sh | 21 +------- build-base-swarm-jenkins-coverage-agent.bat | 27 ++++++++++ build-base-swarm-jenkins-coverage-agent.sh | 35 +++++++++++++ build-edt-k8s-agent.sh | 57 +-------------------- build-edt-swarm-agent.bat | 49 +----------------- build-edt-swarm-agent.sh | 56 +------------------- build-edt.bat | 51 ++++++++++++++++++ build-edt.sh | 56 ++++++++++++++++++++ 12 files changed, 219 insertions(+), 222 deletions(-) create mode 100755 build-base-k8s-jenkins-coverage-agent.sh create mode 100644 build-base-swarm-jenkins-coverage-agent.bat create mode 100755 build-base-swarm-jenkins-coverage-agent.sh create mode 100644 build-edt.bat create mode 100755 build-edt.sh diff --git a/README.md b/README.md index 18aa32d..ced9d3e 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ copy .onec.env.bat.example env.bat * EDT_VERSION - версия EDT. Обязательно заполнять только при сборке образов с EDT или при использовании замеров покрытия (см. `COVERAGE41C_VERSION`) * DOCKER_REGISTRY_URL - Адрес Docker-registry в котором будут храниться образы * COVERAGE41C_VERSION - версия Coverage41C -Если заполнено, то при выполнении скриптов `build-base-*-agent.*` будет также собран образ `base-jenkins-coverage-agent`, подготовленный для сбора замеров покрытия с помощью Coverage41C. Требуется также указать значение для переменной EDT_VERSION. +Используется при сборке агента скриптами `build-base-*-jenkins-coverage-agent.*`. Затем экспортируйте все необходимые переменные: @@ -68,13 +68,13 @@ env.bat 1. Если вам нужны образы для использования в docker-swarm: - * build-base-swarm-jenkins-agent.sh + * build-base-swarm-jenkins-agent.sh (или build-base-swarm-jenkins-coverage-agent.sh с замерами покрытия) * build-edt-swarm-agent.sh * build-oscript-swarm-agent.sh -2. Если же вы планируете использовать k8s +2. Если же вы планируете использовать k8s: - * build-base-k8s-jenkins-agent.sh + * build-base-k8s-jenkins-agent.sh (или build-base-k8s-jenkins-coverage-agent.sh с замерами покрытия) * build-edt-k8s-agent.sh * build-oscript-k8s-agent.sh @@ -216,6 +216,7 @@ docker build --build-arg DOCKER_REGISTRY_URL=${DOCKER_REGISTRY_URL} \ -t ${DOCKER_REGISTRY_URL}/runner:1.7.0 \ -f vanessa-runner/Dockerfile . ``` + ## EDT [(Наверх)](#Оглавление) ```bash diff --git a/build-base-k8s-jenkins-agent.sh b/build-base-k8s-jenkins-agent.sh index 1ded1ad..49fb115 100755 --- a/build-base-k8s-jenkins-agent.sh +++ b/build-base-k8s-jenkins-agent.sh @@ -19,11 +19,6 @@ if [ "${NO_CACHE}" = 'true' ] ; then last_arg='--no-cache .' fi -# если устанавливаем Coverage41C, то предварительно нужно собрать образы EDT -if [[ $COVERAGE41C_VERSION != "" ]] ; then - ./build-edt-k8s-agent.sh -fi - docker build \ --pull \ $no_cache_arg \ @@ -92,18 +87,6 @@ docker build \ -f k8s-jenkins-agent/Dockerfile \ $last_arg -docker push $DOCKER_REGISTRY_URL/base-jenkins-agent:$ONEC_VERSION - -if [[ $COVERAGE41C_VERSION != "" ]] ; then - docker build \ - --build-arg DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL \ - --build-arg BASE_IMAGE=base-jenkins-agent \ - --build-arg BASE_TAG=$ONEC_VERSION \ - --build-arg EDT_VERSION=$EDT_VERSION \ - --build-arg COVERAGE41C_VERSION=$COVERAGE41C_VERSION \ - -t $DOCKER_REGISTRY_URL/base-jenkins-coverage-agent:$ONEC_VERSION \ - -f coverage41C/Dockerfile \ - $last_arg - - docker push $DOCKER_REGISTRY_URL/base-jenkins-coverage-agent:$ONEC_VERSION +if [ -z "$1" ] ; then + docker push $DOCKER_REGISTRY_URL/base-jenkins-agent:$ONEC_VERSION fi diff --git a/build-base-k8s-jenkins-coverage-agent.sh b/build-base-k8s-jenkins-coverage-agent.sh new file mode 100755 index 0000000..090b206 --- /dev/null +++ b/build-base-k8s-jenkins-coverage-agent.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +set -eo pipefail + +if [ -n "${DOCKER_LOGIN}" ] && [ -n "${DOCKER_PASSWORD}" ] && [ -n "${DOCKER_REGISTRY_URL}" ]; then + if ! docker login -u "${DOCKER_LOGIN}" -p "${DOCKER_PASSWORD}" "${DOCKER_REGISTRY_URL}"; then + echo "Docker login failed" + exit 1 + fi +else + echo "Skipping Docker login due to missing credentials" +fi + +if [ "${DOCKER_SYSTEM_PRUNE}" = 'true' ] ; then + docker system prune -af +fi + +last_arg='.' +if [ "${NO_CACHE}" = 'true' ] ; then + last_arg='--no-cache .' +fi + +./build-edt.sh +./build-base-k8s-jenkins-agent.sh "do_not_push_agent" + +docker build \ + --build-arg DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL \ + --build-arg BASE_IMAGE=base-jenkins-agent \ + --build-arg BASE_TAG=$ONEC_VERSION \ + --build-arg EDT_VERSION=$EDT_VERSION \ + --build-arg COVERAGE41C_VERSION=$COVERAGE41C_VERSION \ + -t $DOCKER_REGISTRY_URL/base-jenkins-coverage-agent:$ONEC_VERSION \ + -f coverage41C/Dockerfile \ + $last_arg + +docker push $DOCKER_REGISTRY_URL/base-jenkins-coverage-agent:$ONEC_VERSION diff --git a/build-base-swarm-jenkins-agent.bat b/build-base-swarm-jenkins-agent.bat index 5142751..6c1e196 100644 --- a/build-base-swarm-jenkins-agent.bat +++ b/build-base-swarm-jenkins-agent.bat @@ -10,9 +10,6 @@ if %ERRORLEVEL% neq 0 goto end if %NO_CACHE%=="true" (SET last_arg="--no-cache .") else (SET last_arg=".") -# если устанавливаем Coverage41C, то предварительно нужно собрать образы EDT -if %COVERAGE41C_VERSION% neq "" (.\build-edt-swarm-agent.bat) - docker build ^ --pull ^ --build-arg DOCKER_REGISTRY_URL=library ^ @@ -97,26 +94,11 @@ docker build ^ if %ERRORLEVEL% neq 0 goto end -docker push %DOCKER_REGISTRY_URL%/base-jenkins-agent:%ONEC_VERSION% +IF "%~1"=="" ( + docker push %DOCKER_REGISTRY_URL%/base-jenkins-agent:%ONEC_VERSION% +) if %ERRORLEVEL% neq 0 goto end -if %COVERAGE41C_VERSION% neq "" ( - - docker build ^ - --build-arg DOCKER_REGISTRY_URL=%DOCKER_REGISTRY_URL% ^ - --build-arg BASE_IMAGE=base-jenkins-agent ^ - --build-arg BASE_TAG=%ONEC_VERSION% ^ - --build-arg EDT_VERSION=%EDT_VERSION% ^ - --build-arg COVERAGE41C_VERSION=%COVERAGE41C_VERSION% ^ - -t %DOCKER_REGISTRY_URL%/base-jenkins-coverage-agent:%ONEC_VERSION% ^ - -f coverage41C/Dockerfile ^ - %last_arg% - - -docker push %DOCKER_REGISTRY_URL%/base-jenkins-coverage-agent:%ONEC_VERSION% - -) - :end echo End of program. diff --git a/build-base-swarm-jenkins-agent.sh b/build-base-swarm-jenkins-agent.sh index ad715e3..e99c311 100755 --- a/build-base-swarm-jenkins-agent.sh +++ b/build-base-swarm-jenkins-agent.sh @@ -19,11 +19,6 @@ if [ "${NO_CACHE}" = 'true' ] ; then last_arg='--no-cache .' fi -# если устанавливаем Coverage41C, то предварительно нужно собрать образы EDT -if [[ $COVERAGE41C_VERSION != "" ]] ; then - ./build-edt-swarm-agent.sh -fi - docker build \ --pull \ $no_cache_arg \ @@ -92,18 +87,6 @@ docker build \ -f swarm-jenkins-agent/Dockerfile \ $last_arg -docker push $DOCKER_REGISTRY_URL/base-jenkins-agent:$ONEC_VERSION - -if [[ $COVERAGE41C_VERSION != "" ]] ; then - docker build \ - --build-arg DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL \ - --build-arg BASE_IMAGE=base-jenkins-agent \ - --build-arg BASE_TAG=$ONEC_VERSION \ - --build-arg EDT_VERSION=$EDT_VERSION \ - --build-arg COVERAGE41C_VERSION=$COVERAGE41C_VERSION \ - -t $DOCKER_REGISTRY_URL/base-jenkins-coverage-agent:$ONEC_VERSION \ - -f coverage41C/Dockerfile \ - $last_arg - - docker push $DOCKER_REGISTRY_URL/base-jenkins-coverage-agent:$ONEC_VERSION +if [ -z "$1" ] ; then + docker push $DOCKER_REGISTRY_URL/base-jenkins-agent:$ONEC_VERSION fi diff --git a/build-base-swarm-jenkins-coverage-agent.bat b/build-base-swarm-jenkins-coverage-agent.bat new file mode 100644 index 0000000..1c9f63a --- /dev/null +++ b/build-base-swarm-jenkins-coverage-agent.bat @@ -0,0 +1,27 @@ +@echo off + +docker login -u %DOCKER_LOGIN% -p %DOCKER_PASSWORD% %DOCKER_REGISTRY_URL% + +if %ERRORLEVEL% neq 0 goto end + +if %DOCKER_SYSTEM_PRUNE%=="true" docker system prune -af + +if %ERRORLEVEL% neq 0 goto end + +if %NO_CACHE%=="true" (SET last_arg="--no-cache .") else (SET last_arg=".") + +.\build-edt-swarm-agent.bat +.\build-base-swarm-jenkins-agent.bat "do_not_push_agent" + +docker build ^ + --build-arg DOCKER_REGISTRY_URL=%DOCKER_REGISTRY_URL% ^ + --build-arg BASE_IMAGE=base-jenkins-agent ^ + --build-arg BASE_TAG=%ONEC_VERSION% ^ + --build-arg EDT_VERSION=%EDT_VERSION% ^ + --build-arg COVERAGE41C_VERSION=%COVERAGE41C_VERSION% ^ + -t %DOCKER_REGISTRY_URL%/base-jenkins-coverage-agent:%ONEC_VERSION% ^ + -f coverage41C/Dockerfile ^ + %last_arg% + +docker push %DOCKER_REGISTRY_URL%/base-jenkins-coverage-agent:%ONEC_VERSION% + diff --git a/build-base-swarm-jenkins-coverage-agent.sh b/build-base-swarm-jenkins-coverage-agent.sh new file mode 100755 index 0000000..217f860 --- /dev/null +++ b/build-base-swarm-jenkins-coverage-agent.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +set -eo pipefail + +if [ -n "${DOCKER_LOGIN}" ] && [ -n "${DOCKER_PASSWORD}" ] && [ -n "${DOCKER_REGISTRY_URL}" ]; then + if ! docker login -u "${DOCKER_LOGIN}" -p "${DOCKER_PASSWORD}" "${DOCKER_REGISTRY_URL}"; then + echo "Docker login failed" + exit 1 + fi +else + echo "Skipping Docker login due to missing credentials" +fi + +if [ "${DOCKER_SYSTEM_PRUNE}" = 'true' ] ; then + docker system prune -af +fi + +last_arg='.' +if [ "${NO_CACHE}" = 'true' ] ; then + last_arg='--no-cache .' +fi + +./build-edt.sh +./build-base-swarm-jenkins-agent.sh "do_not_push_agent" + +docker build \ + --build-arg DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL \ + --build-arg BASE_IMAGE=base-jenkins-agent \ + --build-arg BASE_TAG=$ONEC_VERSION \ + --build-arg EDT_VERSION=$EDT_VERSION \ + --build-arg COVERAGE41C_VERSION=$COVERAGE41C_VERSION \ + -t $DOCKER_REGISTRY_URL/base-jenkins-coverage-agent:$ONEC_VERSION \ + -f coverage41C/Dockerfile \ + $last_arg + +docker push $DOCKER_REGISTRY_URL/base-jenkins-coverage-agent:$ONEC_VERSION diff --git a/build-edt-k8s-agent.sh b/build-edt-k8s-agent.sh index 92929f6..d3bf782 100755 --- a/build-edt-k8s-agent.sh +++ b/build-edt-k8s-agent.sh @@ -1,59 +1,4 @@ -#!/usr/bin/env bash -set -eo pipefail - -if [ -n "${DOCKER_LOGIN}" ] && [ -n "${DOCKER_PASSWORD}" ] && [ -n "${DOCKER_REGISTRY_URL}" ]; then - if ! docker login -u "${DOCKER_LOGIN}" -p "${DOCKER_PASSWORD}" "${DOCKER_REGISTRY_URL}"; then - echo "Docker login failed" - exit 1 - fi -else - echo "Skipping Docker login due to missing credentials" -fi - -if [ "${DOCKER_SYSTEM_PRUNE}" = 'true' ] ; then - docker system prune -af -fi - -#Если версия EDT >= 2024.1.0, использовать JDK 17 -if [[ "$(printf "%s\n" "$EDT_VERSION" "2024" | sort -V | head -n 1)" == "2024" ]]; then - BASE_IMAGE="azul/zulu-openjdk" - BASE_TAG="17" -else - BASE_IMAGE="eclipse-temurin" - BASE_TAG="11" -fi - -last_arg='.' -if [ "${NO_CACHE}" = 'true' ] ; then - last_arg='--no-cache .' -fi - -edt_version=$EDT_VERSION -edt_escaped="${edt_version// /_}" - -docker build \ - --pull \ - $no_cache_arg \ - --build-arg DOCKER_REGISTRY_URL=library \ - --build-arg BASE_IMAGE=ubuntu \ - --build-arg BASE_TAG=20.04 \ - --build-arg ONESCRIPT_PACKAGES="yard" \ - -t $DOCKER_REGISTRY_URL/oscript-downloader:latest \ - -f oscript/Dockerfile \ - $last_arg - -docker build \ - --build-arg ONEC_USERNAME=$ONEC_USERNAME \ - --build-arg ONEC_PASSWORD=$ONEC_PASSWORD \ - --build-arg EDT_VERSION="$EDT_VERSION" \ - --build-arg BASE_IMAGE=$BASE_IMAGE \ - --build-arg BASE_TAG=$BASE_TAG \ - --build-arg DOWNLOADER_REGISTRY_URL=$DOCKER_REGISTRY_URL \ - --build-arg DOWNLOADER_IMAGE=oscript-downloader \ - --build-arg DOWNLOADER_TAG=latest \ - -t $DOCKER_REGISTRY_URL/edt:$edt_escaped \ - -f edt/Dockerfile \ - $last_arg +./build-edt.sh docker build \ --build-arg DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL \ diff --git a/build-edt-swarm-agent.bat b/build-edt-swarm-agent.bat index 672afde..135cff8 100644 --- a/build-edt-swarm-agent.bat +++ b/build-edt-swarm-agent.bat @@ -1,53 +1,6 @@ @echo off -docker login -u %DOCKER_LOGIN% -p %DOCKER_PASSWORD% %DOCKER_REGISTRY_URL% - -if %ERRORLEVEL% neq 0 goto end - -if %DOCKER_SYSTEM_PRUNE%=="true" docker system prune -af - -if %ERRORLEVEL% neq 0 goto end - -for /f "delims=." %%a in ("%EDT_VERSION%") do set EDT_MAJOR_VERSION=%aa -if %EDT_MAJOR_VERSION% GEQ "2024" ( - set BASE_IMAGE="azul/zulu-openjdk" - set BASE_TAG="17" -) else ( - set BASE_IMAGE="eclipse-temurin" - set BASE_TAG="11" -) - -if %ERRORLEVEL% neq 0 goto end - -if %NO_CACHE%=="true" (SET last_arg="--no-cache .") else (SET last_arg=".") - -set edt_version=%EDT_VERSION% -set edt_escaped=%edt_version: =_% - -docker build ^ - --pull ^ - --build-arg DOCKER_REGISTRY_URL=library ^ - --build-arg BASE_IMAGE=ubuntu ^ - --build-arg BASE_TAG=20.04 ^ - --build-arg ONESCRIPT_PACKAGES="yard" ^ - -t %DOCKER_REGISTRY_URL%/oscript-downloader:latest ^ - -f oscript/Dockerfile ^ - %last_arg% - -docker build ^ - --build-arg ONEC_USERNAME=%ONEC_USERNAME% ^ - --build-arg ONEC_PASSWORD=%ONEC_PASSWORD% ^ - --build-arg EDT_VERSION=%EDT_VERSION% ^ - --build-arg BASE_IMAGE=%BASE_IMAGE% ^ - --build-arg BASE_TAG=%BASE_TAG% ^ - --build-arg DOCKER_REGISTRY_URL=%DOCKER_REGISTRY_URL% ^ - --build-arg DOWNLOADER_IMAGE=oscript-downloader ^ - --build-arg DOWNLOADER_TAG=latest ^ - -t %DOCKER_REGISTRY_URL%/onec-client:%edt_escaped% ^ - -f edt/Dockerfile ^ - %last_arg% - -if %ERRORLEVEL% neq 0 goto end +.\build-edt.bat docker build ^ --build-arg DOCKER_REGISTRY_URL=%DOCKER_REGISTRY_URL% ^ diff --git a/build-edt-swarm-agent.sh b/build-edt-swarm-agent.sh index fbc6941..eb833bf 100755 --- a/build-edt-swarm-agent.sh +++ b/build-edt-swarm-agent.sh @@ -1,59 +1,5 @@ -#!/usr/bin/env bash -set -eo pipefail -if [ -n "${DOCKER_LOGIN}" ] && [ -n "${DOCKER_PASSWORD}" ] && [ -n "${DOCKER_REGISTRY_URL}" ]; then - if ! docker login -u "${DOCKER_LOGIN}" -p "${DOCKER_PASSWORD}" "${DOCKER_REGISTRY_URL}"; then - echo "Docker login failed" - exit 1 - fi -else - echo "Skipping Docker login due to missing credentials" -fi - -if [ "${DOCKER_SYSTEM_PRUNE}" = 'true' ] ; then - docker system prune -af -fi - -#Если версия EDT >= 2024.1.0, использовать JDK 17 -if [[ "$(printf "%s\n" "$EDT_VERSION" "2024" | sort -V | head -n 1)" == "2024" ]]; then - BASE_IMAGE="azul/zulu-openjdk" - BASE_TAG="17" -else - BASE_IMAGE="eclipse-temurin" - BASE_TAG="11" -fi - -last_arg='.' -if [ "${NO_CACHE}" = 'true' ] ; then - last_arg='--no-cache .' -fi - -edt_version=$EDT_VERSION -edt_escaped="${edt_version// /_}" - -docker build \ - --pull \ - $no_cache_arg \ - --build-arg DOCKER_REGISTRY_URL=library \ - --build-arg BASE_IMAGE=ubuntu \ - --build-arg BASE_TAG=20.04 \ - --build-arg ONESCRIPT_PACKAGES="yard" \ - -t $DOCKER_REGISTRY_URL/oscript-downloader:latest \ - -f oscript/Dockerfile \ - $last_arg - -docker build \ - --build-arg ONEC_USERNAME=$ONEC_USERNAME \ - --build-arg ONEC_PASSWORD=$ONEC_PASSWORD \ - --build-arg EDT_VERSION="$EDT_VERSION" \ - --build-arg BASE_IMAGE=$BASE_IMAGE \ - --build-arg BASE_TAG=$BASE_TAG \ - --build-arg DOWNLOADER_REGISTRY_URL=$DOCKER_REGISTRY_URL \ - --build-arg DOWNLOADER_IMAGE=oscript-downloader \ - --build-arg DOWNLOADER_TAG=latest \ - -t $DOCKER_REGISTRY_URL/edt:$edt_escaped \ - -f edt/Dockerfile \ - $last_arg +./build-edt.sh docker build \ --build-arg DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL \ diff --git a/build-edt.bat b/build-edt.bat new file mode 100644 index 0000000..496d704 --- /dev/null +++ b/build-edt.bat @@ -0,0 +1,51 @@ +@echo off + +docker login -u %DOCKER_LOGIN% -p %DOCKER_PASSWORD% %DOCKER_REGISTRY_URL% + +if %ERRORLEVEL% neq 0 goto end + +if %DOCKER_SYSTEM_PRUNE%=="true" docker system prune -af + +if %ERRORLEVEL% neq 0 goto end + +for /f "delims=." %%a in ("%EDT_VERSION%") do set EDT_MAJOR_VERSION=%aa +if %EDT_MAJOR_VERSION% GEQ "2024" ( + set BASE_IMAGE="azul/zulu-openjdk" + set BASE_TAG="17" +) else ( + set BASE_IMAGE="eclipse-temurin" + set BASE_TAG="11" +) + +if %ERRORLEVEL% neq 0 goto end + +if %NO_CACHE%=="true" (SET last_arg="--no-cache .") else (SET last_arg=".") + +set edt_version=%EDT_VERSION% +set edt_escaped=%edt_version: =_% + +docker build ^ + --pull ^ + --build-arg DOCKER_REGISTRY_URL=library ^ + --build-arg BASE_IMAGE=ubuntu ^ + --build-arg BASE_TAG=20.04 ^ + --build-arg ONESCRIPT_PACKAGES="yard" ^ + -t %DOCKER_REGISTRY_URL%/oscript-downloader:latest ^ + -f oscript/Dockerfile ^ + %last_arg% + +docker build ^ + --build-arg ONEC_USERNAME=%ONEC_USERNAME% ^ + --build-arg ONEC_PASSWORD=%ONEC_PASSWORD% ^ + --build-arg EDT_VERSION=%EDT_VERSION% ^ + --build-arg BASE_IMAGE=%BASE_IMAGE% ^ + --build-arg BASE_TAG=%BASE_TAG% ^ + --build-arg DOCKER_REGISTRY_URL=%DOCKER_REGISTRY_URL% ^ + --build-arg DOWNLOADER_IMAGE=oscript-downloader ^ + --build-arg DOWNLOADER_TAG=latest ^ + -t %DOCKER_REGISTRY_URL%/onec-client:%edt_escaped% ^ + -f edt/Dockerfile ^ + %last_arg% + +if %ERRORLEVEL% neq 0 goto end + diff --git a/build-edt.sh b/build-edt.sh new file mode 100755 index 0000000..a520bcd --- /dev/null +++ b/build-edt.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash +set -eo pipefail + +if [ -n "${DOCKER_LOGIN}" ] && [ -n "${DOCKER_PASSWORD}" ] && [ -n "${DOCKER_REGISTRY_URL}" ]; then + if ! docker login -u "${DOCKER_LOGIN}" -p "${DOCKER_PASSWORD}" "${DOCKER_REGISTRY_URL}"; then + echo "Docker login failed" + exit 1 + fi +else + echo "Skipping Docker login due to missing credentials" +fi + +if [ "${DOCKER_SYSTEM_PRUNE}" = 'true' ] ; then + docker system prune -af +fi + +#Если версия EDT >= 2024.1.0, использовать JDK 17 +if [[ "$(printf "%s\n" "$EDT_VERSION" "2024" | sort -V | head -n 1)" == "2024" ]]; then + BASE_IMAGE="azul/zulu-openjdk" + BASE_TAG="17" +else + BASE_IMAGE="eclipse-temurin" + BASE_TAG="11" +fi + +last_arg='.' +if [ "${NO_CACHE}" = 'true' ] ; then + last_arg='--no-cache .' +fi + +edt_version=$EDT_VERSION +edt_escaped="${edt_version// /_}" + +docker build \ + --pull \ + $no_cache_arg \ + --build-arg DOCKER_REGISTRY_URL=library \ + --build-arg BASE_IMAGE=ubuntu \ + --build-arg BASE_TAG=20.04 \ + --build-arg ONESCRIPT_PACKAGES="yard" \ + -t $DOCKER_REGISTRY_URL/oscript-downloader:latest \ + -f oscript/Dockerfile \ + $last_arg + +docker build \ + --build-arg ONEC_USERNAME=$ONEC_USERNAME \ + --build-arg ONEC_PASSWORD=$ONEC_PASSWORD \ + --build-arg EDT_VERSION="$EDT_VERSION" \ + --build-arg BASE_IMAGE=$BASE_IMAGE \ + --build-arg BASE_TAG=$BASE_TAG \ + --build-arg DOWNLOADER_REGISTRY_URL=$DOCKER_REGISTRY_URL \ + --build-arg DOWNLOADER_IMAGE=oscript-downloader \ + --build-arg DOWNLOADER_TAG=latest \ + -t $DOCKER_REGISTRY_URL/edt:$edt_escaped \ + -f edt/Dockerfile \ + $last_arg From 27011bdfa58b182f4d04d870d2e2b1c3fcfe3c02 Mon Sep 17 00:00:00 2001 From: Dmitry Ovcharenko Date: Thu, 14 Nov 2024 11:26:20 +0300 Subject: [PATCH 5/7] fix edt scripts --- build-edt-k8s-agent.sh | 24 ++++++++++++++++++++++++ build-edt-swarm-agent.bat | 13 +++++++++++++ build-edt-swarm-agent.sh | 23 +++++++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/build-edt-k8s-agent.sh b/build-edt-k8s-agent.sh index d3bf782..408f0a0 100755 --- a/build-edt-k8s-agent.sh +++ b/build-edt-k8s-agent.sh @@ -1,3 +1,27 @@ +#!/usr/bin/env bash +set -eo pipefail + +if [ -n "${DOCKER_LOGIN}" ] && [ -n "${DOCKER_PASSWORD}" ] && [ -n "${DOCKER_REGISTRY_URL}" ]; then + if ! docker login -u "${DOCKER_LOGIN}" -p "${DOCKER_PASSWORD}" "${DOCKER_REGISTRY_URL}"; then + echo "Docker login failed" + exit 1 + fi +else + echo "Skipping Docker login due to missing credentials" +fi + +if [ "${DOCKER_SYSTEM_PRUNE}" = 'true' ] ; then + docker system prune -af +fi + +last_arg='.' +if [ "${NO_CACHE}" = 'true' ] ; then + last_arg='--no-cache .' +fi + +edt_version=$EDT_VERSION +edt_escaped="${edt_version// /_}" + ./build-edt.sh docker build \ diff --git a/build-edt-swarm-agent.bat b/build-edt-swarm-agent.bat index 135cff8..1f3f6b7 100644 --- a/build-edt-swarm-agent.bat +++ b/build-edt-swarm-agent.bat @@ -1,5 +1,18 @@ @echo off +docker login -u %DOCKER_LOGIN% -p %DOCKER_PASSWORD% %DOCKER_REGISTRY_URL% + +if %ERRORLEVEL% neq 0 goto end + +if %DOCKER_SYSTEM_PRUNE%=="true" docker system prune -af + +if %ERRORLEVEL% neq 0 goto end + +if %NO_CACHE%=="true" (SET last_arg="--no-cache .") else (SET last_arg=".") + +set edt_version=%EDT_VERSION% +set edt_escaped=%edt_version: =_% + .\build-edt.bat docker build ^ diff --git a/build-edt-swarm-agent.sh b/build-edt-swarm-agent.sh index eb833bf..95d4a0d 100755 --- a/build-edt-swarm-agent.sh +++ b/build-edt-swarm-agent.sh @@ -1,3 +1,26 @@ +#!/usr/bin/env bash +set -eo pipefail + +if [ -n "${DOCKER_LOGIN}" ] && [ -n "${DOCKER_PASSWORD}" ] && [ -n "${DOCKER_REGISTRY_URL}" ]; then + if ! docker login -u "${DOCKER_LOGIN}" -p "${DOCKER_PASSWORD}" "${DOCKER_REGISTRY_URL}"; then + echo "Docker login failed" + exit 1 + fi +else + echo "Skipping Docker login due to missing credentials" +fi + +if [ "${DOCKER_SYSTEM_PRUNE}" = 'true' ] ; then + docker system prune -af +fi + +last_arg='.' +if [ "${NO_CACHE}" = 'true' ] ; then + last_arg='--no-cache .' +fi + +edt_version=$EDT_VERSION +edt_escaped="${edt_version// /_}" ./build-edt.sh From 67312f1af3a5a28a06cf9ec79fc0cab38e5a0039 Mon Sep 17 00:00:00 2001 From: Dmitry Ovcharenko Date: Sat, 16 Nov 2024 12:22:59 +0300 Subject: [PATCH 6/7] replace argument to env var --- build-base-k8s-jenkins-agent.sh | 2 +- build-base-k8s-jenkins-coverage-agent.sh | 4 +++- build-base-swarm-jenkins-agent.bat | 2 +- build-base-swarm-jenkins-agent.sh | 2 +- build-base-swarm-jenkins-coverage-agent.bat | 4 +++- build-base-swarm-jenkins-coverage-agent.sh | 4 +++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/build-base-k8s-jenkins-agent.sh b/build-base-k8s-jenkins-agent.sh index 49fb115..534440f 100755 --- a/build-base-k8s-jenkins-agent.sh +++ b/build-base-k8s-jenkins-agent.sh @@ -87,6 +87,6 @@ docker build \ -f k8s-jenkins-agent/Dockerfile \ $last_arg -if [ -z "$1" ] ; then +if [[ $PUSH_AGENT != "false" ]] ; then docker push $DOCKER_REGISTRY_URL/base-jenkins-agent:$ONEC_VERSION fi diff --git a/build-base-k8s-jenkins-coverage-agent.sh b/build-base-k8s-jenkins-coverage-agent.sh index 090b206..3c8aa35 100755 --- a/build-base-k8s-jenkins-coverage-agent.sh +++ b/build-base-k8s-jenkins-coverage-agent.sh @@ -20,7 +20,9 @@ if [ "${NO_CACHE}" = 'true' ] ; then fi ./build-edt.sh -./build-base-k8s-jenkins-agent.sh "do_not_push_agent" + +export PUSH_AGENT='false' +./build-base-k8s-jenkins-agent.sh docker build \ --build-arg DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL \ diff --git a/build-base-swarm-jenkins-agent.bat b/build-base-swarm-jenkins-agent.bat index 6c1e196..b9d1c41 100644 --- a/build-base-swarm-jenkins-agent.bat +++ b/build-base-swarm-jenkins-agent.bat @@ -94,7 +94,7 @@ docker build ^ if %ERRORLEVEL% neq 0 goto end -IF "%~1"=="" ( +IF NOT "%PUSH_AGENT%"=="false" ( docker push %DOCKER_REGISTRY_URL%/base-jenkins-agent:%ONEC_VERSION% ) diff --git a/build-base-swarm-jenkins-agent.sh b/build-base-swarm-jenkins-agent.sh index e99c311..96142e7 100755 --- a/build-base-swarm-jenkins-agent.sh +++ b/build-base-swarm-jenkins-agent.sh @@ -87,6 +87,6 @@ docker build \ -f swarm-jenkins-agent/Dockerfile \ $last_arg -if [ -z "$1" ] ; then +if [[ $PUSH_AGENT != "false" ]] ; then docker push $DOCKER_REGISTRY_URL/base-jenkins-agent:$ONEC_VERSION fi diff --git a/build-base-swarm-jenkins-coverage-agent.bat b/build-base-swarm-jenkins-coverage-agent.bat index 1c9f63a..425df1f 100644 --- a/build-base-swarm-jenkins-coverage-agent.bat +++ b/build-base-swarm-jenkins-coverage-agent.bat @@ -11,7 +11,9 @@ if %ERRORLEVEL% neq 0 goto end if %NO_CACHE%=="true" (SET last_arg="--no-cache .") else (SET last_arg=".") .\build-edt-swarm-agent.bat -.\build-base-swarm-jenkins-agent.bat "do_not_push_agent" + +set PUSH_AGENT='false' +.\build-base-swarm-jenkins-agent.bat docker build ^ --build-arg DOCKER_REGISTRY_URL=%DOCKER_REGISTRY_URL% ^ diff --git a/build-base-swarm-jenkins-coverage-agent.sh b/build-base-swarm-jenkins-coverage-agent.sh index 217f860..2055470 100755 --- a/build-base-swarm-jenkins-coverage-agent.sh +++ b/build-base-swarm-jenkins-coverage-agent.sh @@ -20,7 +20,9 @@ if [ "${NO_CACHE}" = 'true' ] ; then fi ./build-edt.sh -./build-base-swarm-jenkins-agent.sh "do_not_push_agent" + +export PUSH_AGENT='false' +./build-base-swarm-jenkins-agent.sh docker build \ --build-arg DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL \ From 011626c95562729b55b7656eb8452cb33b9a749c Mon Sep 17 00:00:00 2001 From: Dima Ovcharenko Date: Sat, 16 Nov 2024 12:30:11 +0300 Subject: [PATCH 7/7] fix quotation Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- build-edt.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-edt.bat b/build-edt.bat index 496d704..2243f6b 100644 --- a/build-edt.bat +++ b/build-edt.bat @@ -4,7 +4,7 @@ docker login -u %DOCKER_LOGIN% -p %DOCKER_PASSWORD% %DOCKER_REGISTRY_URL% if %ERRORLEVEL% neq 0 goto end -if %DOCKER_SYSTEM_PRUNE%=="true" docker system prune -af +if "%DOCKER_SYSTEM_PRUNE%"=="true" docker system prune -af if %ERRORLEVEL% neq 0 goto end