refs TG-2: add test Jenkins

This commit is contained in:
2026-05-02 18:36:24 +03:00
parent 991e853da7
commit c3edeaa9fc
2 changed files with 41 additions and 0 deletions
Vendored
+40
View File
@@ -23,4 +23,44 @@ environment {
}
}
}
post {
always {
withCredentials([string(credentialsId: 'TAIGA_TOKEN', variable: 'TAIGA_TOKEN')]) {
sh '''
set -e
REF=$(git log -1 --pretty=%B | grep -oE 'TG-[0-9]+' | head -1 | cut -d- -f2)
if [ -z "$REF" ]; then
echo "No TG-* reference found"
exit 0
fi
STATUS="${currentBuild.currentResult}"
COMMENT="Jenkins build #${BUILD_NUMBER}: ${STATUS}\\n${BUILD_URL}"
ISSUE_JSON=$(curl -s \
-H "Authorization: Bearer ${TAIGA_TOKEN}" \
"https://taiga.grigowashere.ru/api/v1/issues/by_ref?project=2&ref=${REF}")
ISSUE_ID=$(echo "$ISSUE_JSON" | python3 -c 'import sys,json; print(json.load(sys.stdin)["id"])')
VERSION=$(echo "$ISSUE_JSON" | python3 -c 'import sys,json; print(json.load(sys.stdin)["version"])')
python3 - <<PY > /tmp/taiga-comment.json
import json
comment = """${COMMENT}"""
print(json.dumps({"comment": comment, "version": int("${VERSION}")}))
PY
curl -s -X POST \
-H "Authorization: Bearer ${TAIGA_TOKEN}" \
-H "Content-Type: application/json" \
--data @/tmp/taiga-comment.json \
"https://taiga.grigowashere.ru/api/v1/issues/${ISSUE_ID}/comments"
echo "Commented Taiga TG-${REF}"
'''
}
}
}
}