forked from FennyLiang/cargocms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
100 lines (78 loc) · 2.46 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
node {
try {
// slackSend message: "started ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
echo "BRANCH_NAME = " + env.BRANCH_NAME
def BRANCH_NAME = env.BRANCH_NAME;
def preview = false;
def skiptest = false;
def deploy = false;
try{
if(BRANCH_NAME == "release-labfnp"){
deploy = true;
// skiptest = true;
preview = false;
} else {
timeout(time:10, unit:'SECONDS') {
stage 'preview'
input message: "wanner preview?", ok: "start preview"
}
preview = true;
}
if(deploy){
timeout(time:5, unit:'SECONDS') {
stage 'do test'
input message: "do test?", ok: "do test"
}
skiptest = false;
}
if(preview){
timeout(time:5, unit:'SECONDS') {
stage 'skip test'
input message: "skip test?", ok: "skip test"
}
skiptest = true;
}
}catch(e){
}
stage 'checkout project'
// git url: 'https://github.com/trunk-studio/cargocms.git', branch: 'develop'
checkout scm
if(!skiptest){
stage 'check env'
sh "node -v"
stage 'build project'
sh "npm install && npm run build"
stage 'test project'
sh "npm run test-ci"
// step([$class: 'JUnitResultArchiver', testResults: 'test-results.xml'])
// step([$class: 'CloverPublisher', cloverReportDir: 'coverage', cloverReportFileName: 'clover.xml'])
sh "npm run test-e2e-docker"
}
if(preview) sh "npm run preview"
if(deploy) sh "make deploy-beta"
// stage 'run project'
// sh "npm run pm2-start"
//
// try{
// stage 'Approve, go production'
// def url = 'http://localhost:1337/'
// input message: "Does staging at $url look good? ", ok: "Deploy to production"
// }finally{
// sh "npm run pm2-stop"
// }
//
// stage 'package production'
// sh "make package-production"
// step([$class: 'ArtifactArchiver', artifacts: 'sailsSampleProd.tar.gz', fingerprint: true])
//
// stage 'deploy production'
// sh "make deploy-production-legacy"
//
// stage 'restart production'
// sh "make restart-production"
slackSend color: 'good', message: "success ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
}catch(e){
slackSend color: 'danger', message: "fail ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
throw e;
}
}