refs TG-2: add test Jenkins2
This commit is contained in:
Vendored
+25
-23
@@ -23,44 +23,46 @@ environment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
always {
|
always {
|
||||||
|
script {
|
||||||
|
def result = currentBuild.currentResult ?: 'UNKNOWN'
|
||||||
|
|
||||||
withCredentials([string(credentialsId: 'TAIGA_TOKEN', variable: 'TAIGA_TOKEN')]) {
|
withCredentials([string(credentialsId: 'TAIGA_TOKEN', variable: 'TAIGA_TOKEN')]) {
|
||||||
sh '''
|
sh """
|
||||||
set -e
|
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"
|
echo "No TG-* reference found"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
STATUS="${currentBuild.currentResult}"
|
ISSUE_JSON=\$(curl -s \\
|
||||||
COMMENT="Jenkins build #${BUILD_NUMBER}: ${STATUS}\\n${BUILD_URL}"
|
-H "Authorization: Bearer \$TAIGA_TOKEN" \\
|
||||||
|
"https://taiga.grigowashere.ru/api/v1/issues/by_ref?project=2&ref=\$REF")
|
||||||
|
|
||||||
ISSUE_JSON=$(curl -s \
|
ISSUE_ID=\$(echo "\$ISSUE_JSON" | python3 -c 'import sys,json; print(json.load(sys.stdin)["id"])')
|
||||||
-H "Authorization: Bearer ${TAIGA_TOKEN}" \
|
VERSION=\$(echo "\$ISSUE_JSON" | python3 -c 'import sys,json; print(json.load(sys.stdin)["version"])')
|
||||||
"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"])')
|
export COMMENT="Jenkins build #${BUILD_NUMBER}: ${result}
|
||||||
VERSION=$(echo "$ISSUE_JSON" | python3 -c 'import sys,json; print(json.load(sys.stdin)["version"])')
|
${BUILD_URL}"
|
||||||
|
export VERSION="\$VERSION"
|
||||||
|
|
||||||
python3 - <<PY > /tmp/taiga-comment.json
|
python3 -c 'import json, os; print(json.dumps({"comment": os.environ["COMMENT"], "version": int(os.environ["VERSION"])}))' \\
|
||||||
import json
|
> /tmp/taiga-comment.json
|
||||||
comment = """${COMMENT}"""
|
|
||||||
print(json.dumps({"comment": comment, "version": int("${VERSION}")}))
|
|
||||||
PY
|
|
||||||
|
|
||||||
curl -s -X POST \
|
curl -s -X POST \\
|
||||||
-H "Authorization: Bearer ${TAIGA_TOKEN}" \
|
-H "Authorization: Bearer \$TAIGA_TOKEN" \\
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \\
|
||||||
--data @/tmp/taiga-comment.json \
|
--data @/tmp/taiga-comment.json \\
|
||||||
"https://taiga.grigowashere.ru/api/v1/issues/${ISSUE_ID}/comments"
|
"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