feat: finalize projectwork CI jobs, docs and test integration

This commit is contained in:
2026-04-23 11:39:08 +03:00
parent 737bddd631
commit 20bdacf5c5
39 changed files with 1819 additions and 70 deletions
+56 -1
View File
@@ -22,6 +22,7 @@ pipeline {
steps {
sh '''
set -eux
git config --global --add safe.directory '*' || true
rm -rf ./sources
git clone "${QA_REPO_URL}" ./sources
git -C ./sources checkout "${QA_REPO_REF}"
@@ -40,7 +41,7 @@ pipeline {
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")"
CID="$(docker create localhost:5005/otus/test-api:1.0.0 bash -lc "set -e; cd /workspace; mvn -f citrus-tests/pom.xml -Dallure.results.directory=target/allure-results test")"
cleanup_container() {
docker rm -f "${CID}" >/dev/null 2>&1 || true
}
@@ -50,6 +51,53 @@ pipeline {
docker start -a "${CID}"
TEST_RC=$?
docker cp "${CID}:/workspace/citrus-tests/target" "./artifacts/citrus-target" || true
mkdir -p ./artifacts/citrus-target/allure-results
if ! ls ./artifacts/citrus-target/allure-results/* >/dev/null 2>&1; then
EXTRA_UUID="$(cat /proc/sys/kernel/random/uuid)"
TS_MS="$(( $(date +%s) * 1000 ))"
STATUS="passed"
if [ "${TEST_RC}" -ne 0 ]; then
STATUS="failed"
fi
cat > "./artifacts/citrus-target/allure-results/${EXTRA_UUID}-result.json" <<EOF
{
"uuid": "${EXTRA_UUID}",
"historyId": "api-citrus-summary-${BUILD_NUMBER}",
"name": "API Citrus pipeline summary",
"fullName": "pipeline.ApiCitrusSummary",
"status": "${STATUS}",
"stage": "finished",
"start": ${TS_MS},
"stop": ${TS_MS},
"labels": [
{"name": "suite", "value": "Pipeline"},
{"name": "package", "value": "pipeline"},
{"name": "testClass", "value": "ApiCitrusSummary"},
{"name": "testMethod", "value": "run"}
],
"steps": [],
"parameters": []
}
EOF
fi
{
echo "job=${JOB_NAME}"
echo "build=${BUILD_NUMBER}"
echo "repo.url=${QA_REPO_URL}"
echo "repo.ref=${QA_REPO_REF}"
echo "repo.sha=${GIT_SHA}"
} > ./artifacts/citrus-target/allure-results/environment.properties
cat > ./artifacts/citrus-target/allure-results/executor.json <<EOF
{
"name": "Jenkins",
"type": "jenkins",
"url": "${JENKINS_URL}",
"buildName": "${JOB_NAME} #${BUILD_NUMBER}",
"buildUrl": "${BUILD_URL}",
"reportUrl": "${BUILD_URL}allure",
"buildOrder": ${BUILD_NUMBER}
}
EOF
trap - EXIT INT TERM
docker rm -f "${CID}" || true
exit "${TEST_RC}"
@@ -59,6 +107,13 @@ pipeline {
}
post {
always {
script {
try {
allure commandline: 'allure', includeProperties: false, jdk: '', results: [[path: 'artifacts/citrus-target/allure-results']]
} catch (Exception ex) {
echo "Allure publisher unavailable: ${ex.message}"
}
}
junit allowEmptyResults: true, testResults: 'artifacts/citrus-target/surefire-reports/*.xml'
archiveArtifacts allowEmptyArchive: true, artifacts: 'artifacts/run-info.txt,artifacts/citrus-target/**'
}