-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathJenkinsfile
63 lines (62 loc) · 1.73 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
@Library('lisk-jenkins') _
pipeline {
agent { node { label 'lisk-build' } }
options {
skipDefaultCheckout()
timeout(time: 30, unit: 'MINUTES')
}
stages {
stage('Checkout SCM') {
steps {
cleanWs()
checkout scm
sh '''
VERSION=$( jq --raw-output '.version' package.json )
SHORT_HASH=$( git rev-parse --short HEAD )
echo "$VERSION-$SHORT_HASH" >.lisk_version
OUTPUT_FILE="lisk-$( cat .lisk_version )-Linux-x86_64.tar.gz"
if s3cmd --quiet info "s3://lisk-releases/lisk-core/$OUTPUT_FILE" 2>/dev/null; then
echo "Build already exists."
exit 1
fi
'''
}
}
stage('Build Core') {
steps {
withCredentials([string(credentialsId: 'npm-lisk-io-auth-token-jenkins', variable: 'REGISTRY_AUTH_TOKEN')]) {
sh '''
if [ "x$BRANCH_NAME" != "xmaster" ]; then
echo 'registry=https://npm.lisk.io/\n//npm.lisk.io/:_authToken=$REGISTRY_AUTH_TOKEN"' >~/.npmrc
fi
'''
}
dir('build') {
sh 'make LISK_NETWORK=testnet'
}
}
}
stage('Upload build') {
steps {
dir('build/release') {
sh '''
VERSION=$( jq --raw-output '.version' ../../package.json )
OUTPUT_FILE="lisk-$( cat ../../.lisk_version )-Linux-x86_64.tar.gz"
mkdir "${OUTPUT_FILE%.tar.gz}"
tar xf "lisk-$VERSION-Linux-x86_64.tar.gz" --strip-components=1 --directory="${OUTPUT_FILE%.tar.gz}"
tar czf "$OUTPUT_FILE" "${OUTPUT_FILE%.tar.gz}"
sha256sum "$OUTPUT_FILE" >"$OUTPUT_FILE.SHA256"
s3cmd put --acl-public "$OUTPUT_FILE" "s3://lisk-releases/lisk-core/$OUTPUT_FILE"
s3cmd put --acl-public "$OUTPUT_FILE.SHA256" "s3://lisk-releases/lisk-core/$OUTPUT_FILE.SHA256"
'''
}
}
}
}
post {
always {
sh 'rm -f ~/.npmrc'
}
}
}
// vim: filetype=groovy