forked from teambit/bit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile-linux
81 lines (67 loc) · 3.56 KB
/
Jenkinsfile-linux
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
node {
//properties([[$class: 'ParametersDefinitionProperty', parameterDefinitions: [[$class: 'ChoiceParameterDefinition', choices: 'stage\nproduction', description: '', name: 'environment']]]])
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/teambit/bit.git']]])
// checkout scm
def releaseServer = "${env.BIT_STAGE_SERVER}" + "/update"
def repo = "${env.EXTERNAL_REPO}"
def app = "bit"
def currentVersion = sh script: 'cat package.json | grep version | head -1 | awk -F: \'{ print $2 }\' | sed \'s/[",]//g\' ' , returnStdout: true
currentVersion = currentVersion.replaceAll("\\s","")
def bundleName = "bit_${currentVersion}"
def uploadfolder = "gs://bit-assets/release/${currentVersion}/"
stage 'remove old zip files '
sh("rm -rf *.tar.gz && rm -rf ./distribution")
sh("rm -rf ./node_modules")
stage 'Running tar'
sh('./scripts/build-tar.sh')
stage 'Running DEB & RPM'
sh('./scripts/build-deb.sh')
stage 'Run test'
parallel (
"stream 1" : {
sh("docker run -v `pwd`/distribution:/packages -v `pwd`/tests:/tests gcr.io/cocycles-963/containers/bit-testing-centos:latest")
},
"stream 2" : {
sh("docker run -v `pwd`/distribution:/packages -v `pwd`/tests:/tests gcr.io/cocycles-963/containers/bit-testing-ubuntu:latest")
}
)
stage 'move tar to distribution'
sh("mv bit-${currentVersion}.tar.gz ./distribution")
stage 'deploy to repository'
def debUrl = "${repo}/bit-deb/development/bit/${currentVersion}/bit_${currentVersion}_all.deb;deb.distribution=all;deb.component=development;deb.architecture=amd64"
sh("curl -u${REPO_TOKEN} -T ./distribution/bit_${currentVersion}_all.deb -XPUT '${debUrl}'")
deployToArtifactory("rpm","bit-yum/development/bit/${currentVersion}","${currentVersion}-1.noarch",null)
deployToArtifactory("tar.gz","bit-tar/development/bit/${currentVersion}","${currentVersion}","bit-tar/development/bit/${currentVersion}/")
stage 'notify release server'
notifyReleaseServer(currentVersion,releaseServer,"${repo}/bit-deb/development/bit/${currentVersion}/bit_${currentVersion}_all.deb","deb")
notifyReleaseServer(currentVersion,releaseServer,"${repo}/bit-yum/development/bit/${currentVersion}/bit-${currentVersion}-1.noarch.rpm","yum")
notifyReleaseServer(currentVersion,releaseServer,"${repo}/bit-tar/development/bit/${currentVersion}/bit-${currentVersion}-tar.gz","tar")
stage ("upload repo scripts")
sh("gsutil -m cp -a public-read repos/bitsrc.repo gs://bit-assets/")
sh("curl -X PURGE http://assets.bitsrc.io/bitsrc.repo")
}
def deployToArtifactory(artifactSuffix,repo,version,target){
def currentTarget = "${repo}/"
if (target != null) {
currentTarget =target
}
def server = Artifactory.server 'Bitsrc-artifactory'
def uploadSpec = """{
"files": [
{
"pattern": "distribution/bit-${version}.${artifactSuffix}",
"target": "${currentTarget}"
}
]
}"""
server.upload(uploadSpec)
}
import groovy.json.JsonOutput
def notifyReleaseServer(version,url,packageUrl,method) {
def payload = JsonOutput.toJson(version : version,
method: "${method}",
file: "${packageUrl}")
def post = "curl -d '${payload.toString()}' -H 'Content-Type: application/json' ${url} -u ${releaseServerToken} "
print ("${post}")
sh ("${post}")
}