|
1 | 1 | #!/usr/bin/env bash |
2 | | -# Publish the successful Jenkins gate as durable, SHA-bound evidence. |
| 2 | +# Archive the successful Jenkins gate as durable, SHA-bound evidence. |
3 | 3 | set -euo pipefail |
4 | 4 |
|
5 | 5 | ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" |
6 | 6 | cd "$ROOT" |
7 | 7 |
|
8 | | -: "${GH_TOKEN:?GH_TOKEN is required to publish Jenkins evidence}" |
9 | | -REPOSITORY="${GITHUB_REPOSITORY:-ngallodev/codebase-memory-cli}" |
10 | 8 | CONTEXT="${CBM_JENKINS_STATUS_CONTEXT:-jenkins/codebase-memory-cli-main/full-gate}" |
11 | 9 | REVISION="${GIT_COMMIT:-$(git rev-parse HEAD)}" |
12 | 10 | EVIDENCE_DIR="${CBM_JENKINS_EVIDENCE_DIR:-jenkins-evidence}" |
13 | 11 |
|
14 | | -# Jenkins builds this checkout from the local working tree, so publish the |
15 | | -# tested revision before asking GitHub to attach a SHA-bound status to it. |
16 | | -PUSH_ASKPASS="$(mktemp)" |
17 | | -trap 'rm -f "$PUSH_ASKPASS"' EXIT |
18 | | -# shellcheck disable=SC2016 # The helper must expand its own prompt and token. |
19 | | -printf '%s\n' '#!/bin/sh' 'case "$1" in' \ |
20 | | - '*Username*) printf "%s\\n" x-access-token ;;' \ |
21 | | - '*Password*) printf "%s\\n" "$GH_TOKEN" ;;' \ |
22 | | - '*) exit 1 ;;' 'esac' > "$PUSH_ASKPASS" |
23 | | -chmod 700 "$PUSH_ASKPASS" |
24 | | -GIT_ASKPASS="$PUSH_ASKPASS" GIT_TERMINAL_PROMPT=0 \ |
25 | | - git push "https://github.com/$REPOSITORY.git" 'HEAD:refs/heads/main' |
26 | | - |
| 12 | +# Validation archives evidence locally. The orchestrator pushes release-tooling |
| 13 | +# and publishes the SHA-bound GitHub status only after this job succeeds. |
27 | 14 | rm -rf "$EVIDENCE_DIR" |
28 | 15 | mkdir -p "$EVIDENCE_DIR" |
29 | 16 |
|
|
48 | 35 | find "$EVIDENCE_DIR" -type f ! -name SHA256SUMS -print0 \ |
49 | 36 | | sort -z | xargs -0 sha256sum > "$EVIDENCE_DIR/SHA256SUMS" |
50 | 37 |
|
51 | | -GH_TOKEN="$GH_TOKEN" gh api --method POST \ |
52 | | - "repos/$REPOSITORY/statuses/$REVISION" \ |
53 | | - -f state=success \ |
54 | | - -f context="$CONTEXT" \ |
55 | | - -f description="Jenkins full gate passed; SHA-bound evidence archived in build ${BUILD_NUMBER:-unknown}" \ |
56 | | - -f target_url="${BUILD_URL:-}" \ |
57 | | - >/dev/null |
58 | | - |
59 | | -echo "Published $CONTEXT for $REVISION" |
| 38 | +echo "Archived $CONTEXT for $REVISION" |
0 commit comments