-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathJenkinsfile
65 lines (53 loc) · 1.03 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
#!groovy
pipeline {
agent any
stages {
stage('check environment') {
steps {
prepare_env()
}
}
stage('checkout') {
steps {
checkout scm
}
}
stage('install dependencies') {
steps {
install_dep()
}
}
stage('build') {
steps {
run_build()
}
}
stage('deploy') {
steps {
deploy(env.BRANCH_NAME)
}
}
}
}
def prepare_env () {
if (env.BRANCH_NAME == "production") {
env.DEV_ENV = "production"
} else {
env.DEV_ENV = "staging"
}
env.NODE_ENV = "${env.DEV_ENV}"
}
def run_build () {
sh "npm run build"
}
def install_dep () {
sh "npm i"
sh "npm run bower-setup"
}
def deploy(branch) {
def channel = "production"
if (branch == "master") {
channel = "staging"
}
sh "npm run deploy-${channel}"
}