forked from storj-archived/storj.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
68 lines (50 loc) · 1.81 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
node('node') {
try {
stage 'Checkout'
checkout scm
stage 'Build Docker'
sh "git rev-parse --short HEAD > .git/commit-id"
def commit_id = readFile('.git/commit-id').trim()
echo 'Build dockerfile'
sh "./dockerfiles/build/build-storj.io.sh ${env.BUILD_ID} ${commit_id} latest"
echo 'Push to Repo'
sh "./dockerfiles/build/push.sh storjlabs/storj.io:${env.BUILD_ID} storjlabs/storj.io:${commit_id} storjlabs/storj.io:latest"
stage 'Deploy'
def prod_deploy_enabled = false
def staging_tag = sh(returnStdout: true, script: "git tag | grep 'staging'").trim()
echo "staging_tag is: $staging_tag"
if (staging_tag == 'staging') {
sh(returnStdout: true, script: "./dockerfiles/deploy/deploy.staging.sh storj-website deployment storjlabs/storj.io:${commit_id}")
}
echo "Branch name: ${env.BRANCH_NAME}"
if (env.BRANCH_NAME == 'master' && prod_deploy_enabled == true) {
sh(returnStdout: true, script: "./dockerfiles/deploy/deploy.production.sh storj-website deployment storjlabs/storj.io:${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"
echo 'Caught ERROR!'
echo "Error: ${err}"
/*
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
*/
}
}