Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Доработки для использования замеров покрытия с помощью Coverage41C на агентах swarm и k8s #44

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .onec.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
- [oscript](#oscript)
- [vanessa-runner](#vanessa-runner)
- [EDT](#edt)

# Использование

В терминале введите:
Expand All @@ -46,7 +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-*-jenkins-coverage-agent.*`.

Затем экспортируйте все необходимые переменные:

Expand All @@ -65,11 +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
* build-base-k8s-jenkins-agent.sh

2. Если же вы планируете использовать k8s:

* build-base-k8s-jenkins-agent.sh (или build-base-k8s-jenkins-coverage-agent.sh с замерами покрытия)
* build-edt-k8s-agent.sh
* build-oscript-k8s-agent.sh

Expand All @@ -81,7 +86,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`

## Сервер
[(Наверх)](#Оглавление)
Expand Down Expand Up @@ -211,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
Expand Down
4 changes: 3 additions & 1 deletion build-base-k8s-jenkins-agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,6 @@ docker build \
-f k8s-jenkins-agent/Dockerfile \
$last_arg

docker push $DOCKER_REGISTRY_URL/base-jenkins-agent:$ONEC_VERSION
if [[ $PUSH_AGENT != "false" ]] ; then
docker push $DOCKER_REGISTRY_URL/base-jenkins-agent:$ONEC_VERSION
ovcharenko-di marked this conversation as resolved.
Show resolved Hide resolved
fi
37 changes: 37 additions & 0 deletions build-base-k8s-jenkins-coverage-agent.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/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
ovcharenko-di marked this conversation as resolved.
Show resolved Hide resolved

if [ "${DOCKER_SYSTEM_PRUNE}" = 'true' ] ; then
docker system prune -af
fi
ovcharenko-di marked this conversation as resolved.
Show resolved Hide resolved

last_arg='.'
if [ "${NO_CACHE}" = 'true' ] ; then
last_arg='--no-cache .'
fi

./build-edt.sh

export PUSH_AGENT='false'
./build-base-k8s-jenkins-agent.sh

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
ovcharenko-di marked this conversation as resolved.
Show resolved Hide resolved
7 changes: 4 additions & 3 deletions build-base-swarm-jenkins-agent.bat
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ if %ERRORLEVEL% neq 0 goto end

if %NO_CACHE%=="true" (SET last_arg="--no-cache .") else (SET last_arg=".")


docker build ^
--pull ^
--build-arg DOCKER_REGISTRY_URL=library ^
Expand Down Expand Up @@ -95,9 +94,11 @@ docker build ^

if %ERRORLEVEL% neq 0 goto end

docker push %DOCKER_REGISTRY_URL%/base-jenkins-agent:%ONEC_VERSION%
IF NOT "%PUSH_AGENT%"=="false" (
docker push %DOCKER_REGISTRY_URL%/base-jenkins-agent:%ONEC_VERSION%
)

if %ERRORLEVEL% neq 0 goto end

:end
echo End of program.
echo End of program.
4 changes: 3 additions & 1 deletion build-base-swarm-jenkins-agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,6 @@ docker build \
-f swarm-jenkins-agent/Dockerfile \
$last_arg

docker push $DOCKER_REGISTRY_URL/base-jenkins-agent:$ONEC_VERSION
if [[ $PUSH_AGENT != "false" ]] ; then
docker push $DOCKER_REGISTRY_URL/base-jenkins-agent:$ONEC_VERSION
fi
29 changes: 29 additions & 0 deletions build-base-swarm-jenkins-coverage-agent.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@echo off

docker login -u %DOCKER_LOGIN% -p %DOCKER_PASSWORD% %DOCKER_REGISTRY_URL%

if %ERRORLEVEL% neq 0 goto end
ovcharenko-di marked this conversation as resolved.
Show resolved Hide resolved

if %DOCKER_SYSTEM_PRUNE%=="true" docker system prune -af

if %ERRORLEVEL% neq 0 goto end
ovcharenko-di marked this conversation as resolved.
Show resolved Hide resolved

if %NO_CACHE%=="true" (SET last_arg="--no-cache .") else (SET last_arg=".")
ovcharenko-di marked this conversation as resolved.
Show resolved Hide resolved

.\build-edt-swarm-agent.bat

set PUSH_AGENT='false'
.\build-base-swarm-jenkins-agent.bat

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%
ovcharenko-di marked this conversation as resolved.
Show resolved Hide resolved

docker push %DOCKER_REGISTRY_URL%/base-jenkins-coverage-agent:%ONEC_VERSION%
ovcharenko-di marked this conversation as resolved.
Show resolved Hide resolved

37 changes: 37 additions & 0 deletions build-base-swarm-jenkins-coverage-agent.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
set -eo pipefail
nixel2007 marked this conversation as resolved.
Show resolved Hide resolved

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
ovcharenko-di marked this conversation as resolved.
Show resolved Hide resolved

if [ "${DOCKER_SYSTEM_PRUNE}" = 'true' ] ; then
docker system prune -af
fi
ovcharenko-di marked this conversation as resolved.
Show resolved Hide resolved

last_arg='.'
if [ "${NO_CACHE}" = 'true' ] ; then
last_arg='--no-cache .'
fi

./build-edt.sh

export PUSH_AGENT='false'
./build-base-swarm-jenkins-agent.sh

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
ovcharenko-di marked this conversation as resolved.
Show resolved Hide resolved
33 changes: 1 addition & 32 deletions build-edt-k8s-agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@ 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 .'
Expand All @@ -31,29 +22,7 @@ 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
ovcharenko-di marked this conversation as resolved.
Show resolved Hide resolved

docker build \
--build-arg DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL \
Expand Down
36 changes: 1 addition & 35 deletions build-edt-swarm-agent.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,12 @@ 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
ovcharenko-di marked this conversation as resolved.
Show resolved Hide resolved

docker build ^
--build-arg DOCKER_REGISTRY_URL=%DOCKER_REGISTRY_URL% ^
Expand Down
33 changes: 1 addition & 32 deletions build-edt-swarm-agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@ 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 .'
Expand All @@ -31,29 +22,7 @@ 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
ovcharenko-di marked this conversation as resolved.
Show resolved Hide resolved

docker build \
--build-arg DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL \
Expand Down
Loading