ci: stabilize Jenkins jobs and mobile pipeline

This commit is contained in:
2026-04-22 11:27:23 +03:00
parent caf057d712
commit 737bddd631
23 changed files with 762 additions and 66 deletions
+30 -2
View File
@@ -5,19 +5,47 @@ pipeline {
ansiColor('xterm')
}
stages {
stage('Prepare Metadata') {
steps {
script {
wrap([$class: 'BuildUser']) {
env.RUN_TRIGGER_USER = env.BUILD_USER_ID ?: env.BUILD_USER ?: 'system'
env.RUN_TRIGGER_NAME = env.BUILD_USER ?: env.BUILD_USER_ID ?: 'system'
}
currentBuild.displayName = "#${env.BUILD_NUMBER} api"
currentBuild.description =
"by=${env.RUN_TRIGGER_NAME}; repo=${params.QA_REPO_URL}; ref=${params.QA_REPO_REF}"
}
}
}
stage('Run API Tests In Docker') {
steps {
sh '''
set -eux
rm -rf ./sources
git clone "${QA_REPO_URL}" ./sources
git -C ./sources checkout "${QA_REPO_REF}"
GIT_SHA="$(git -C ./sources rev-parse --short HEAD)"
rm -rf ./artifacts
mkdir -p ./artifacts
{
echo "job=${JOB_NAME}"
echo "build=${BUILD_NUMBER}"
echo "trigger_user=${RUN_TRIGGER_USER}"
echo "trigger_name=${RUN_TRIGGER_NAME}"
echo "qa_repo_url=${QA_REPO_URL}"
echo "qa_repo_ref=${QA_REPO_REF}"
echo "qa_repo_sha=${GIT_SHA}"
echo "timestamp_utc=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
} > ./artifacts/run-info.txt
CID="$(docker create localhost:5005/otus/test-api:1.0.0 bash -lc "set -e; cd /workspace; mvn -f citrus-tests/pom.xml test")"
cleanup_container() {
docker rm -f "${CID}" >/dev/null 2>&1 || true
}
trap cleanup_container EXIT INT TERM
tar -C /workspace/otus-autotests/homework_4 -cf - . | docker cp - "${CID}:/workspace"
tar -C ./sources -cf - . | docker cp - "${CID}:/workspace"
set +e
docker start -a "${CID}"
TEST_RC=$?
@@ -32,7 +60,7 @@ pipeline {
post {
always {
junit allowEmptyResults: true, testResults: 'artifacts/citrus-target/surefire-reports/*.xml'
archiveArtifacts allowEmptyArchive: true, artifacts: 'artifacts/citrus-target/**'
archiveArtifacts allowEmptyArchive: true, artifacts: 'artifacts/run-info.txt,artifacts/citrus-target/**'
}
}
}