-
Notifications
You must be signed in to change notification settings - Fork 3
/
Jenkinsfile
128 lines (124 loc) · 4.13 KB
/
Jenkinsfile
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
pipeline {
agent {
node {
label 'node'
}
}
stages {
stage('Install dependencies') {
parallel {
stage('JavaScript') {
steps {
sh 'CI=true npm_config_python=/usr/local/bin/python2.7 yarn --no-progress --non-interactive --skip-integrity-check --frozen-lockfile install'
}
}
stage('Python') {
steps {
sh 'poetry install'
}
}
}
}
stage('Type checks') {
parallel {
stage('TypeScript') {
steps {
sh 'node_modules/.bin/tsc -p tsconfig.json --noEmit --extendedDiagnostics'
}
}
stage('MyPy (stateserver)') {
steps {
sh 'poetry run mypy stateserver.py'
}
}
stage('MyPy (shittyserver)') {
steps {
sh 'poetry run mypy shittyserver.py'
}
}
}
}
stage('Build and deploy to dev instance') {
when {
anyOf {
branch 'master'
branch 'production'
}
}
environment {
SENTRY_AUTH_TOKEN = credentials('sentry-auth-token')
SENTRY_ORG = 'university-radio-york'
SENTRY_PROJECT = 'webstudio'
SENTRY_ENVIRONMENT = 'webstudio-dev'
}
steps {
sh 'jq \'.homepage = "https://ury.org.uk/webstudio-dev"\' package.json > package-replace.json && mv package-replace.json package.json'
sh 'REACT_APP_GIT_SHA=`git rev-parse --short HEAD` yarn build'
sshagent(credentials: ['ury']) {
sh 'rsync -av --delete-after build/ deploy@ury:/usr/local/www/webstudio-dev'
}
}
post {
success {
sh '''
export SENTRY_RELEASE="$(jq -r '.version' package.json)-$(git rev-parse --short HEAD)"
sentry-cli releases new -p $SENTRY_PROJECT $SENTRY_RELEASE
sentry-cli releases set-commits $SENTRY_RELEASE --auto
sentry-cli releases files $SENTRY_RELEASE upload-sourcemaps build/static/js --url-prefix '/webstudio-dev/static/js'
sentry-cli releases finalize $SENTRY_RELEASE
sentry-cli releases deploys $SENTRY_RELEASE new -e $SENTRY_ENVIRONMENT
'''
}
}
}
stage('Build and deploy for production') {
when {
branch 'production'
}
environment {
SENTRY_AUTH_TOKEN = credentials('sentry-auth-token')
SENTRY_ORG = 'university-radio-york'
SENTRY_PROJECT = 'webstudio'
SENTRY_ENVIRONMENT = 'production'
}
parallel {
stage('Deploy prod client') {
environment {
REACT_APP_MYRADIO_NONAPI_BASE = 'https://ury.org.uk/myradio'
REACT_APP_MYRADIO_BASE = 'https://ury.org.uk/api/v2'
REACT_APP_WS_URL = 'wss://ury.org.uk/webstudio/api/stream'
}
steps {
sh 'sed -i -e \'s/ury.org.uk\\/webstudio-dev/ury.org.uk\\/webstudio/\' package.json'
sh 'REACT_APP_GIT_SHA=`git rev-parse --short HEAD` REACT_APP_PRODUCTION=true yarn build'
sshagent(credentials: ['ury']) {
sh 'rsync -av --delete-after build/ deploy@ury:/usr/local/www/webstudio'
}
}
post {
success {
sh '''
export SENTRY_RELEASE="$(jq -r '.version' package.json)-$(git rev-parse --short HEAD)"
sentry-cli releases new -p $SENTRY_PROJECT $SENTRY_RELEASE
sentry-cli releases set-commits $SENTRY_RELEASE --auto
sentry-cli releases files $SENTRY_RELEASE upload-sourcemaps build/static/js --url-prefix '/webstudio/static/js'
sentry-cli releases finalize $SENTRY_RELEASE
sentry-cli releases deploys $SENTRY_RELEASE new -e $SENTRY_ENVIRONMENT
'''
}
}
}
stage('Deploy server') {
steps {
sshagent(credentials: ['ury']) {
sh 'scp -v -o StrictHostKeyChecking=no stateserver.py [email protected]:/opt/webstudioserver/stateserver.py'
sh 'scp -v -o StrictHostKeyChecking=no shittyserver.py [email protected]:/opt/webstudioserver/shittyserver.py'
sh 'scp -v -o StrictHostKeyChecking=no pyproject.toml [email protected]:/opt/webstudioserver/pyproject.toml'
sh 'scp -v -o StrictHostKeyChecking=no poetry.lock [email protected]:/opt/webstudioserver/poetry.lock'
}
}
}
}
}
}
}