-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
84 lines (78 loc) · 2.58 KB
/
Copy pathJenkinsfile
File metadata and controls
84 lines (78 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Observatory — Tier 2 CI/CD Pipeline
//
// CONTEXT
// Observatory hosts the hn-hrcb site (CF Pages) and cron worker (CF Worker).
// Tier 1 (GitHub Actions deploy.yml) handles Cloudflare deploys directly.
// This Jenkins pipeline adds build validation and provides a fallback
// deploy path through forge.safety-quotient.dev.
//
// The observatory also runs meshd on chromabook (:8079) — but meshd is
// built and deployed from the psychology-agent repo's Jenkinsfile, not here.
// This pipeline covers only observatory-specific artifacts.
//
// BUILD TRIGGER
// Builds trigger via a GitHub Actions relay (.github/workflows/trigger-forge.yml).
// See that file for why a relay is needed (Cloudflare Access authentication).
// SCM polling serves as a fallback.
//
// Required credentials (Jenkins > Manage > Credentials):
// 'cloudflare-workers-token' — CF API token (Secret text)
// 'cloudflare-account-id' — CF account ID (Secret text)
pipeline {
agent any
environment {
CLOUDFLARE_API_TOKEN = credentials('cloudflare-workers-token')
CLOUDFLARE_ACCOUNT_ID = credentials('cloudflare-account-id')
}
stages {
// Build the observatory site and verify output.
stage('Build Site') {
when {
changeset 'site/**'
}
steps {
dir('site') {
sh 'npm ci && npm run build'
sh '''
COUNT=$(find dist -name "*.html" | wc -l)
echo "Pages built: $COUNT"
if [ "$COUNT" -lt 1 ]; then
echo "ERROR: No HTML pages generated"
exit 1
fi
'''
}
}
}
// Deploy site to Cloudflare Pages (fallback for Tier 1).
stage('Deploy Site') {
when {
changeset 'site/**'
}
steps {
dir('site') {
sh 'npx wrangler pages deploy dist --project-name=hn-hrcb'
}
}
}
// Deploy cron worker to Cloudflare (fallback for Tier 1).
stage('Deploy Cron Worker') {
when {
changeset 'worker/**'
}
steps {
dir('worker') {
sh 'npx wrangler deploy'
}
}
}
}
post {
success {
echo "Build succeeded: ${env.BUILD_URL}"
}
failure {
echo "Build failed: ${env.BUILD_URL}"
}
}
}