This repository has been archived by the owner on Oct 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
/
Jenkinsfile
67 lines (52 loc) · 1.91 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
node('node') {
try {
stage 'Checkout'
checkout scm
stage 'Test'
sh """#!/bin/bash -e
source '/var/lib/jenkins/.nvm/nvm.sh'
node -v
git clean -fdx
npm install
npm test
"""
stage 'Build Docker'
sh "git rev-parse --short HEAD > .git/commit-id"
def commit_id = readFile('.git/commit-id').trim()
sh "./dockerfiles/build-bridge.sh storjlabs/bridge:${env.BUILD_ID} storjlabs/bridge:${commit_id} storjlabs/bridge:latest"
sh "./dockerfiles/build-storj-monitor.sh storjlabs/storj-monitor:${env.BUILD_ID} storjlabs/storj-monitor:${commit_id} storjlabs/storj-monitor:latest"
sh "./dockerfiles/push.sh storjlabs/bridge:${env.BUILD_ID} storjlabs/bridge:${commit_id} storjlabs/bridge:latest"
sh "./dockerfiles/push.sh storjlabs/storj-monitor:${env.BUILD_ID} storjlabs/storj-monitor:${commit_id} storjlabs/storj-monitor:latest"
stage 'Deploy'
/* This should only deploy to staging if the branch is master */
if (env.BRANCH_NAME == "master") {
echo 'Push to Repo'
sh "./dockerfiles/deploy.staging.sh bridge-api storjlabs/bridge:${commit_id}"
sh "./dockerfiles/deploy.staging.sh storj-monitor storjlabs/storj-monitor:${commit_id}"
}
stage 'Cleanup'
echo 'prune and cleanup'
sh """#!/bin/bash -e
source '/var/lib/jenkins/.nvm/nvm.sh'
rm node_modules -rf
"""
/*
mail body: 'project build successful',
from: '[email protected]',
replyTo: '[email protected]',
subject: 'project build successful',
to: "${env.CHANGE_AUTHOR_EMAIL}"
*/
}
catch (err) {
currentBuild.result = "FAILURE"
/*
mail body: "project build error is here: ${env.BUILD_URL}" ,
from: '[email protected]',
replyTo: '[email protected]',
subject: 'project build failed',
to: "${env.CHANGE_AUTHOR_EMAIL}"
throw err
*/
}
}