ci: jenkins-trigger-and-wait.sh — fire job + poll for SUCCESS
This commit is contained in:
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
SCRIPT="$ROOT/scripts/ci/jenkins-trigger-and-wait.sh"
|
||||
[ -x "$SCRIPT" ] || { echo "FAIL: $SCRIPT not executable"; exit 1; }
|
||||
|
||||
# Mock-mode tests need jq — bail with a useful message if unavailable.
|
||||
command -v jq >/dev/null 2>&1 || { echo "SKIP: jq not installed"; exit 0; }
|
||||
|
||||
# --- success path ---
|
||||
if ! "$SCRIPT" --mock-mode "$ROOT/tests/ci/fixtures/jenkins-success-flow.json" 2>&1 | tee /tmp/jenkins-test.log; then
|
||||
echo "FAIL: success fixture should exit 0"
|
||||
exit 1
|
||||
fi
|
||||
grep -q "build #42 SUCCESS" /tmp/jenkins-test.log || { echo "FAIL: expected 'build #42 SUCCESS'"; exit 1; }
|
||||
|
||||
# --- failure path ---
|
||||
if "$SCRIPT" --mock-mode "$ROOT/tests/ci/fixtures/jenkins-failure-flow.json" 2>&1 | tee /tmp/jenkins-test.log; then
|
||||
echo "FAIL: failure fixture should exit non-zero"
|
||||
exit 1
|
||||
fi
|
||||
grep -q "FAILURE" /tmp/jenkins-test.log || { echo "FAIL: expected 'FAILURE' in output"; exit 1; }
|
||||
|
||||
# --- bad usage ---
|
||||
if "$SCRIPT" 2>/dev/null; then
|
||||
echo "FAIL: expected usage error"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "PASS: jenkins-trigger-and-wait.sh"
|
||||
Reference in New Issue
Block a user