forked from jenkins-infra/plugin-site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile_k8s
150 lines (141 loc) · 3.16 KB
/
Jenkinsfile_k8s
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
pipeline {
agent {
kubernetes {
inheritFrom 'jnlp-linux'
yaml '''
apiVersion: "v1"
kind: "Pod"
metadata:
labels:
jenkins: "agent"
job: "plugin-site"
spec:
tolerations:
- key: "os"
operator: "Equal"
value: "linux"
effect: "NoSchedule"
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/os
operator: In
values:
- linux
restartPolicy: "Never"
containers:
- name: "node"
image: "node:14.17"
securityContext:
privileged: false
tty: true
command:
- cat
- name: "blobxfer"
image: "mcr.microsoft.com/blobxfer:1.9.1"
command:
- cat
securityContext:
privileged: false
tty: true
'''
}
}
environment {
TZ = "UTC"
GET_CONTENT = "true"
NODE_ENV = "production"
HOME = "${WORKSPACE}"
GATSBY_MATOMO_SITE_ID = "1"
GATSBY_MATOMO_SITE_URL = "https://jenkins-matomo.do.g4v.dev"
}
triggers {
cron('H H/3 * * *')
}
options {
timeout(time: 60, unit: 'MINUTES')
ansiColor('xterm')
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '5', numToKeepStr: '5')
}
stages {
stage('NPM Install') {
steps {
container('node') {
sh 'NODE_ENV=development npm ci'
}
}
}
stage('Build PR') {
when {
not {
branch "master"
}
}
steps {
container('node') {
sh 'npm run build'
}
}
}
stage('Build Production') {
when {
branch "master"
}
environment {
GATSBY_SENTRY_DSN = "https://495b0bd32a5e4a2287c3fe4b061ee24f@sentry.io/1882460"
GATSBY_ALGOLIA_APP_ID = credentials('algolia-plugins-app-id')
GATSBY_ALGOLIA_SEARCH_KEY = credentials('algolia-plugins-search-key')
GATSBY_ALGOLIA_WRITE_KEY = credentials('algolia-plugins-write-key')
}
steps {
container('node') {
sh 'npm run build'
}
}
}
stage('Check build') {
steps {
container('node') {
sh 'test -e public/index.html || exit 1'
}
}
}
stage('Lint and Test') {
environment {
NODE_ENV = "development"
}
steps {
container('node') {
sh 'npm run lint'
sh 'npm run test'
}
}
}
stage('Deploy to azure') {
when {
branch "master"
}
environment {
PLUGINSITE_STORAGEACCOUNTKEY = credentials('PLUGINSITE_STORAGEACCOUNTKEY')
}
steps {
container('blobxfer') {
sh('''blobxfer upload \
--local-path public \
--storage-account-key $PLUGINSITE_STORAGEACCOUNTKEY \
--storage-account prodpluginsite \
--remote-path pluginsite \
--recursive \
--mode file \
--skip-on-md5-match \
--file-md5 \
--connect-timeout 30 \
--delete
''')
}
}
}
}
}