refs TG-2: add test Jenkins2
This commit is contained in:
Vendored
+26
-24
@@ -23,44 +23,46 @@ environment {
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
post {
|
||||
always {
|
||||
script {
|
||||
def result = currentBuild.currentResult ?: 'UNKNOWN'
|
||||
|
||||
withCredentials([string(credentialsId: 'TAIGA_TOKEN', variable: 'TAIGA_TOKEN')]) {
|
||||
sh '''
|
||||
sh """
|
||||
set -e
|
||||
|
||||
REF=$(git log -1 --pretty=%B | grep -oE 'TG-[0-9]+' | head -1 | cut -d- -f2)
|
||||
REF=\$(git log -1 --pretty=%B | grep -oE 'TG-[0-9]+' | head -1 | cut -d- -f2 || true)
|
||||
|
||||
if [ -z "$REF" ]; then
|
||||
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_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"])')
|
||||
|
||||
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"])')
|
||||
export COMMENT="Jenkins build #${BUILD_NUMBER}: ${result}
|
||||
${BUILD_URL}"
|
||||
export VERSION="\$VERSION"
|
||||
|
||||
python3 - <<PY > /tmp/taiga-comment.json
|
||||
import json
|
||||
comment = """${COMMENT}"""
|
||||
print(json.dumps({"comment": comment, "version": int("${VERSION}")}))
|
||||
PY
|
||||
python3 -c 'import json, os; print(json.dumps({"comment": os.environ["COMMENT"], "version": int(os.environ["VERSION"])}))' \\
|
||||
> /tmp/taiga-comment.json
|
||||
|
||||
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"
|
||||
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}"
|
||||
'''
|
||||
echo "Commented Taiga TG-\$REF"
|
||||
""".stripIndent()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user