-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathJenkinsfile
117 lines (112 loc) · 3.24 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
/* -*- mode: groovy -*- */
// dontKillMe
// jenkins will kill any process spawned during the job
// https://wiki.jenkins.io/display/JENKINS/ProcessTreeKiller
pipeline {
options {
buildDiscarder logRotator(artifactDaysToKeepStr: '30', artifactNumToKeepStr: '50', daysToKeepStr: '60', numToKeepStr: '50')
disableConcurrentBuilds()
disableResume()
durabilityHint 'PERFORMANCE_OPTIMIZED'
timestamps()
}
agent none
stages {
stage('test') {
agent {label 'bounty-backend-test-machine'}
steps {
nodejs(nodeJSInstallationName: 'nodejs15') {
script {
sh (label: 'pre-build', script: "yarn")
}
script {
sh (label: 'lint', script: "yarn lint")
}
}
}
}
stage('multiple env') {
parallel {
stage('ci env') {
when {
beforeAgent true
anyOf {
branch 'dev'
branch 'jenkins-pipeline'
}
}
agent {label 'bounty-backend-test-machine'}
steps {
nodejs(nodeJSInstallationName: 'nodejs15') {
script {
sh (label: 'pre-build', script: "yarn")
}
script {
sh (label: 'build', script: "yarn build")
}
}
script {
sh (label: 'move to nginx www', script: """
sudo rm -rf /www/bounty/web || true
sudo mkdir -p /www/bounty/web
sudo cp -r dist /www/bounty/web/
""")
}
}
}
stage('staging env') {
when {
beforeAgent true
allOf {
environment name: 'CHANGE_TARGET', value: 'master'
}
}
agent {label 'bounty-backend-staging-machine'}
steps {
nodejs(nodeJSInstallationName: 'nodejs15') {
script {
sh (label: 'pre-build', script: "yarn")
}
withCredentials([file(credentialsId: 'ali-oss-prod-key', variable: 'ALI_OSS_PROD_KEY')]) {
sh (label: 'build', script: 'JENKINS_ALI_OSS_KEYS=$(cat $ALI_OSS_PROD_KEY) yarn build')
}
}
script {
sh (label: 'move to nginx www', script: """
sudo rm -rf /www/bounty/web/staging || true
sudo mkdir -p /www/bounty/web/staging
sudo cp -r dist /www/bounty/web/staging/
""")
}
}
}
stage('prod env') {
when {
beforeAgent true
allOf {
branch 'master'
}
}
agent {label 'bounty-frontend-production-node'}
steps {
nodejs(nodeJSInstallationName: 'nodejs15') {
script {
sh (label: 'pre-build', script: "yarn")
}
withCredentials([file(credentialsId: 'ali-oss-prod-key', variable: 'ALI_OSS_PROD_KEY')]) {
sh (label: 'build', script: 'JENKINS_ALI_OSS_KEYS=$(cat $ALI_OSS_PROD_KEY) yarn build')
}
}
script {
sh (label: 'move to nginx www', script: """
sudo mkdir -p /www/bounty/web
sudo rm -rf /www/bounty/web/dist || true
sudo cp -r dist /www/bounty/web/
""")
}
}
}
}
}
}
}