forked from teambit/bit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkins-publish
78 lines (71 loc) · 3.39 KB
/
Jenkins-publish
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
node {
checkout scm
tarName = "bit-${VERSION}.tar.gz"
brewTarName = "bit-${VERSION}-brew.tar.gz"
debpkg="bit_${VERSION}_all.deb"
rpm="bit-${VERSION}-1.noarch.rpm"
msi="bit-${VERSION}-unsigned.msi"
def uploadfolder = "gs://bit-assets/release/${VERSION}/"
parallel (
"deb" : {
if (params.deb){
sh("wget ${env.EXTERNAL_REPO}/bit-deb/development/bit/${VERSION}/${debpkg} ")
def fullUrl = "${env.EXTERNAL_REPO}/bit-deb/stable/bit/${VERSION}/bit_${VERSION}_all.deb;deb.distribution=all;deb.component=stable;deb.architecture=amd64"
sh("curl -u${REPO_TOKEN} -T ${debpkg} -XPUT '${fullUrl}'")
notifyReleaseServer("${VERSION}","${env.EXTERNAL_REPO}/bit-deb/stable/bit/${VERSION}/bit_${VERSION}_all.deb","deb")
}
},
"rpm" : {
if (params.yum){
publishToRepo("bit-yum/development/bit/${VERSION}/${rpm}","bit-yum/stable/bit/${VERSION}/${rpm}")
notifyReleaseServer("${VERSION}","${env.EXTERNAL_REPO}/bit-yum/stable/bit/${VERSION}/${rpm}","yum")
}
},
"msi" : {
if (params.msi){
publishToRepo("bit-msi/development/bit/${VERSION}/${msi}","bit-msi/stable/bit/${VERSION}/${msi}")
notifyReleaseServer("${VERSION}","${env.EXTERNAL_REPO}/bit-msi/stable/bit/${VERSION}/${msi}","msi")
notifyAppveyor()
}
},
"brew" : {
if (params.brew){
publishToRepo("bit-brew/development/bit/${VERSION}/${brewTarName}","bit-brew/stable/bit/${VERSION}/${brewTarName}")
sh("./scripts/generate-formula.sh ${env.EXTERNAL_REPO}/bit-brew/stable/bit/${VERSION}/${brewTarName}")
sh("cd ./distribution && gsutil -m cp bit.rb ${uploadfolder}")
//def sha = sh returnStdout: true, script: '$( curl -s "${env.EXTERNAL_REPO}/bit-brew/stable/bit/${VERSION}/${brewTarName}" |shasum -b -a 256| cut -d \' \' -f 1 )'
//sh("brew bump-formula-pr --url=${env.EXTERNAL_REPO}/bit-brew/stable/bit/${VERSION}/${brewTarName} --sha256=${sha}")
}
},
"tar" : {
if (params.tar){
publishToRepo("bit-tar/development/bit/${VERSION}/${tarName}","bit-tar/stable/bit/${VERSION}/${tarName}")
notifyReleaseServer("${VERSION}","${env.EXTERNAL_REPO}/bit-tar/stable/bit/${VERSION}/bit-${VERSION}.tar.gz","tar")
}
}
)
}
def publishToRepo(from,to){
def fullUrl = "${env.EXTERNAL_REPO}/api/copy/${from}?to=${to}"
sh("curl -u${REPO_TOKEN} -XPOST '${fullUrl}'")
}
import groovy.json.JsonOutput
def notifyReleaseServer(version,packageUrl,method) {
def payload = JsonOutput.toJson(version : version,
method: "${method}",
file: "${packageUrl}")
print(payload)
def post = "curl -d '${payload.toString()}' -H 'Content-Type: application/json' ${env.BIT_PROD_SERVER}/update -u ${releaseServerToken}"
print ("${post}")
sh ("${post}")
}
import groovy.json.JsonOutput
def notifyAppveyor(){
def payload = JsonOutput.toJson(accountName : 'TeamBit',
projectSlug: "bit-mr045",
branch: "master")
print(payload)
def post = "curl -X POST -d '${payload.toString()}' -H 'Content-Type: application/json' -H 'Authorization: Bearer ${env.APPVEYOR_TOKEN} ' ${env.APPVEYOR_CI}"
print (post)
sh ("${post}")
}