forked from teambit/bit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
76 lines (58 loc) · 2.68 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
node {
properties([[$class: 'ParametersDefinitionProperty', parameterDefinitions: [[$class: 'ChoiceParameterDefinition', choices: 'stage\nproduction', description: '', name: 'environment']]]])
checkout scm
def releaseServer = "${env.BIT_STAGE_SERVER}"
def assets = "${env.BIT_ASSETS}"
print releaseServer
def env = "${environment}"
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('cd ./scripts && ./build-tar.sh tar')
stage 'Running brew'
sh("cd ./scripts && ./build-brew.sh ")
stage 'Running deb'
sh('cd ./scripts && ./build-deb.sh')
//stage 'export to google storage'
//sh("gsutil -m cp -a public-read ./distribution/brew_pkg/${bundleName}_brew.tar.gz ${uploadfolder}")
//sh("gsutil -m cp -a public-read ./distribution/*.deb ${uploadfolder}")
//sh("gsutil -m cp -a public-read ./distribution/*.rpm ${uploadfolder}")
//stage 'notify release server'
//notifyReleaseServer(currentVersion,releaseServer+"/update")
stage 'generate formula for brew'
sh("cd ./scripts && ./generate-formula.sh ${assets}/${currentVersion}/${bundleName}_brew.tar.gz")
// sh("cd ./distribution && gsutil -m cp bit.rb ${uploadfolder}")
//sh("curl -X PURGE http://assets.bitsrc.io/release/${currentVersion}/bit_${currentVersion}_brew.tar.gz")
deployToArtifactory("deb","bit-deb",currentVersion)
deployToArtifactory("rpm","bit-yum","${currentVersion}-*")
}
def deployToArtifactory(artifactSuffix,repo,version){
def server = Artifactory.server 'Bitsrc-artifactory'
def uploadSpec = """{
"files": [
{
"pattern": "./distribution/bit-${version}.${artifactSuffix}",
"target": "${repo}/bit/"
}
]
}"""
server.upload(uploadSpec)
}
import groovy.json.JsonOutput
def notifyReleaseServer(version,url) {
def payload = JsonOutput.toJson([version : version,
brew: "bit-${version}_brew.tar.gz",
deb: "bit-${version}_deb.deb",
rpm: "bit-${version}_deb.deb",
msi:"bit-${version}.msi"])
print(payload)
def post = "curl -d '${payload.toString()}' -H 'Content-Type: application/json' ${url}"
print ("${post}")
sh ("${post}")
}