Skip to content

Commit f77252b

Browse files
committed
fix(ci): archive Jenkins evidence without publishing source
1 parent 7e9005f commit f77252b

3 files changed

Lines changed: 13 additions & 31 deletions

File tree

‎Jenkinsfile‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,16 +229,12 @@ arena hash_table dyn_array str_intern log str_util workspace platform diagnostic
229229
sh 'scripts/test.sh --tsan'
230230
}
231231
}
232-
stage('Publish Jenkins qualification evidence') {
232+
stage('Archive Jenkins qualification evidence') {
233233
when {
234234
expression { !params.CBM_TEST_SUITES?.trim() }
235235
}
236236
steps {
237-
withCredentials([usernamePassword(credentialsId: 'github-https-token',
238-
usernameVariable: 'GITHUB_USER',
239-
passwordVariable: 'GH_TOKEN')]) {
240-
sh 'GITHUB_REPOSITORY=ngallodev/codebase-memory-cli scripts/ci/publish-jenkins-evidence.sh'
241-
}
237+
sh 'scripts/ci/publish-jenkins-evidence.sh'
242238
archiveArtifacts artifacts: 'jenkins-evidence/**', fingerprint: true
243239
}
244240
}
Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,16 @@
11
#!/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.
33
set -euo pipefail
44

55
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
66
cd "$ROOT"
77

8-
: "${GH_TOKEN:?GH_TOKEN is required to publish Jenkins evidence}"
9-
REPOSITORY="${GITHUB_REPOSITORY:-ngallodev/codebase-memory-cli}"
108
CONTEXT="${CBM_JENKINS_STATUS_CONTEXT:-jenkins/codebase-memory-cli-main/full-gate}"
119
REVISION="${GIT_COMMIT:-$(git rev-parse HEAD)}"
1210
EVIDENCE_DIR="${CBM_JENKINS_EVIDENCE_DIR:-jenkins-evidence}"
1311

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.
2714
rm -rf "$EVIDENCE_DIR"
2815
mkdir -p "$EVIDENCE_DIR"
2916

@@ -48,12 +35,4 @@ fi
4835
find "$EVIDENCE_DIR" -type f ! -name SHA256SUMS -print0 \
4936
| sort -z | xargs -0 sha256sum > "$EVIDENCE_DIR/SHA256SUMS"
5037

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"

‎tests/test_jenkins_artifact_contract.sh‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,10 @@ grep -Fq 'requirements-ci.txt' "$root/scripts/ci/install-python-tools.sh" || {
2727
echo "missing CI Python requirements contract" >&2
2828
exit 1
2929
}
30+
31+
# The validator must never publish source or require GitHub write credentials.
32+
evidence="$root/scripts/ci/publish-jenkins-evidence.sh"
33+
if grep -Eq 'git[[:space:]]+push|gh[[:space:]]+api|GIT_ASKPASS|GH_TOKEN|github-https-token' "$evidence"; then
34+
echo "Jenkins validation must archive evidence without remote writes" >&2
35+
exit 1
36+
fi

0 commit comments

Comments
 (0)