ghprbGhRepository="ceph/ceph"
fi
+# For manually-triggered jobs, report the final result back to GitHub as a
+# commit status (webhook-triggered jobs get this from the PR Builder plugin).
+# Installed as an EXIT trap so it fires no matter which stage (make check, dep
+# install, or API tests) the job exits on, including the docs-only early exit
+# below (which reports success).
+trap 'report_github_pr_status $? "ceph API tests"' EXIT
+
+# Report that the job has started (manual triggers only).
+update_github_pr_status "pending" "running API tests" "ceph API tests"
+
docs_pr_only
container_pr_only
gha_pr_only
credential-id: github-readonly-token
username: GITHUB_USER
password: GITHUB_PASS
+ - username-password-separated:
+ credential-id: github-status-check-token
+ username: GITHUB_STATUS_USER
+ password: GITHUB_STATUS_TOKEN
- project:
name: ceph-api-project
#!/bin/bash -ex
+# For manually-triggered jobs, report the final result back to GitHub as a
+# commit status (webhook-triggered jobs get this from the PR Builder plugin).
+# Installed as an EXIT trap so it fires no matter where the job exits, including
+# the docs-only early exit below (which reports success).
+trap 'report_github_pr_status $? "make check (arm64)" "make check"' EXIT
+
+# Report that the job has started (manual triggers only).
+update_github_pr_status "pending" "running make check" "make check (arm64)"
+
docs_pr_only
container_pr_only
gha_pr_only
npm_cache_info
sleep 5
ps -ef | grep -v jnlp | grep ceph || true
+
+# `bwc -e tests` exits 0 even when individual tests fail so that the CTest
+# results are always published; the xUnit publisher is what fails the build (its
+# threshold fails on any failed test). A non-test failure (e.g. compile) would
+# have aborted above under `set -e`. Mirror xUnit here so the EXIT trap reports
+# the matching GitHub status for manual triggers.
+test_xml="$(find build/Testing -name Test.xml 2>/dev/null)"
+if [ -n "$test_xml" ] && grep -q 'Status="failed"' $test_xml; then
+ echo "CTest reported one or more failed tests; marking the build as failed."
+ exit 1
+fi
credential-id: github-readonly-token
username: GITHUB_USER
password: GITHUB_PASS
+ - username-password-separated:
+ credential-id: github-status-check-token
+ username: GITHUB_STATUS_USER
+ password: GITHUB_STATUS_TOKEN
- username-password-separated:
credential-id: dgalloway-docker-hub
username: DOCKER_HUB_USERNAME
#!/bin/bash -ex
+# For manually-triggered jobs, report the final result back to GitHub as a
+# commit status (webhook-triggered jobs get this from the PR Builder plugin).
+# Installed as an EXIT trap so it fires no matter where the job exits, including
+# the docs-only early exit below (which reports success).
+trap 'report_github_pr_status $? "make check"' EXIT
+
+# Report that the job has started (manual triggers only).
+update_github_pr_status "pending" "running make check" "make check"
+
docs_pr_only
container_pr_only
gha_pr_only
npm_cache_info
sleep 5
ps -ef | grep -v jnlp | grep ceph || true
+
+# `bwc -e tests` exits 0 even when individual tests fail so that the CTest
+# results are always published; the xUnit publisher is what fails the build (its
+# threshold fails on any failed test). A non-test failure (e.g. compile) would
+# have aborted above under `set -e`. Mirror xUnit here so the EXIT trap reports
+# the matching GitHub status for manual triggers.
+test_xml="$(find build/Testing -name Test.xml 2>/dev/null)"
+if [ -n "$test_xml" ] && grep -q 'Status="failed"' $test_xml; then
+ echo "CTest reported one or more failed tests; marking the build as failed."
+ exit 1
+fi
credential-id: github-readonly-token
username: GITHUB_USER
password: GITHUB_PASS
+ - username-password-separated:
+ credential-id: github-status-check-token
+ username: GITHUB_STATUS_USER
+ password: GITHUB_STATUS_TOKEN
- username-password-separated:
credential-id: dgalloway-docker-hub
username: DOCKER_HUB_USERNAME
set -o errexit
set -o pipefail
+# For manually-triggered jobs, report the final result back to GitHub as a
+# commit status (webhook-triggered jobs get this from the PR Builder plugin).
+# Installed as an EXIT trap so a failure anywhere in the setup stages (or the
+# docs-only early exit below) is reported. Note: run_tests installs its own
+# EXIT trap later in the chain which supersedes this one and also reports.
+trap 'report_github_pr_status $? "ceph windows tests"' EXIT
+
+# Report that the job has started (manual triggers only).
+update_github_pr_status "pending" "running ceph windows tests" "ceph windows tests"
+
docs_pr_only
container_pr_only
gha_pr_only
credential-id: github-readonly-token
username: GITHUB_USER
password: GITHUB_PASS
+ - username-password-separated:
+ credential-id: github-status-check-token
+ username: GITHUB_STATUS_USER
+ password: GITHUB_STATUS_TOKEN
}
+# Report a Pull Request job's result back to GitHub as a commit status (check).
+# The GitHub Pull Request Builder plugin does this automatically when a webhook
+# triggers the job, but manually-triggered jobs don't get that, so post the
+# status directly via the GitHub API.
+# $1 - state: one of pending, success, failure, error
+# $2 - description shown alongside the check (optional)
+# $3 - status context/name (optional, defaults to "make check")
+# $4 - target URL the check links to in the GitHub UI (optional, defaults to
+# this Jenkins build's URL)
+update_github_pr_status() {
+ local state=$1
+ local description=$2
+ local context=${3:-"make check"}
+ # Link the check back to this Jenkins build so clicking the context in the
+ # GitHub UI opens the job.
+ local target_url=${4:-$BUILD_URL}
+
+ # Only post a status for manually-triggered jobs. Webhook-triggered jobs
+ # already have their status managed by the GitHub Pull Request Builder plugin,
+ # so posting here would just be a duplicate. Check ROOT_BUILD_CAUSE too so a
+ # job kicked off down an upstream chain from a manual trigger is still covered.
+ if [ "$BUILD_CAUSE" != "MANUALTRIGGER" ] && [ "$ROOT_BUILD_CAUSE" != "MANUALTRIGGER" ]; then
+ return 0
+ fi
+
+ # Manually-triggered jobs don't have the ghprb* variables set by the plugin.
+ # Assume ceph/ceph and look up the PR's head commit from the GitHub API.
+ ghprbGhRepository="ceph/ceph"
+ ghprbActualCommit="$(curl -s -u ${GITHUB_USER}:${GITHUB_PASS} https://api.github.com/repos/${ghprbGhRepository}/pulls/${ghprbPullId} | jq -r '.head.sha')"
+
+ if [ -z "$ghprbActualCommit" ] || [ -z "$ghprbGhRepository" ]; then
+ echo "Could not determine commit or repository; skipping GitHub status update"
+ return 0
+ fi
+
+ echo "Setting GitHub status '$context' to '$state' for ${ghprbGhRepository}@${ghprbActualCommit}"
+ # Posting a status needs a token with write access, unlike the read-only token
+ # in GITHUB_USER/GITHUB_PASS used for the lookup above.
+ curl -s -u ${GITHUB_STATUS_USER}:${GITHUB_STATUS_TOKEN} \
+ -X POST \
+ -H "Accept: application/vnd.github+json" \
+ "https://api.github.com/repos/${ghprbGhRepository}/statuses/${ghprbActualCommit}" \
+ -d "$(jq -n \
+ --arg state "$state" \
+ --arg target_url "$target_url" \
+ --arg description "$description" \
+ --arg context "$context" \
+ '{state: $state, target_url: $target_url, description: $description, context: $context}')"
+}
+
+# Convenience wrapper meant to be installed as a bash EXIT trap so a Pull Request
+# job reports its overall pass/fail to GitHub regardless of which stage failed.
+# Like update_github_pr_status, it's a no-op unless the job was triggered
+# manually. Pass $? explicitly from the trap so the exit code is captured before
+# anything in this function clobbers it, e.g.:
+# trap 'report_github_pr_status $? "make check"' EXIT
+# $1 - exit code (0 == success)
+# $2 - status context/name (e.g. "make check (arm64)")
+# $3 - label used in the description (optional, defaults to $2)
+report_github_pr_status() {
+ local rc=$1
+ local context=$2
+ local label=${3:-$context}
+ if [ "$rc" -eq 0 ]; then
+ update_github_pr_status "success" "$label succeeded" "$context"
+ else
+ update_github_pr_status "failure" "$label failed" "$context"
+ fi
+}
+
write_collect_logs_playbook() {
cat > $WORKSPACE/collect-logs.yml << EOF
- hosts: all
scp_download /workspace/eventlogs $WORKSPACE/artifacts/client/eventlogs
echo "Successfully retrieved artifacts."
}
-trap collect_artifacts EXIT
+#
+# On exit, report the result to GitHub (manual triggers only) and then collect
+# artifacts. $? is captured first so the job's real exit code is reported
+# before anything in the trap clobbers it.
+#
+function on_exit() {
+ local rc=$?
+ report_github_pr_status $rc "ceph windows tests"
+ collect_artifacts
+}
+trap on_exit EXIT
# View cluster status before test run
SSH_USER=$UBUNTU_SSH_USER SSH_ADDRESS=$UBUNTU_VM_IP ssh_exec ./ceph/build/bin/ceph status