forked from teambit/bit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile-brew
63 lines (50 loc) · 2.55 KB
/
Jenkinsfile-brew
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
node {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/teambit/bit.git']]])
//properties([[$class: 'ParametersDefinitionProperty', parameterDefinitions: [[$class: 'ChoiceParameterDefinition', choices: 'stage\nproduction', description: '', name: 'environment']]]])
//checkout scm
def releaseServer = "${env.BIT_STAGE_SERVER}"
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 tarName ="bit-${currentVersion}-brew.tar.gz"
brewTarName = "bit-${currentVersion}-brew.tar.gz"
def uploadfolder = "gs://bit-assets/release/${currentVersion}"
try {
stage 'remove old zip files '
sh("rm -rf *.tar.gz && rm -rf ./distribution")
sh("rm -rf ./node_modules")
sh("rm -rf ./components")
stage 'Running tar'
sh('./scripts/build-tar.sh mac')
stage 'Running brew'
sh("./scripts/build-brew.sh ")
stage 'upload to repo'
def server = Artifactory.server 'Bitsrc-artifactory'
def uploadSpec = """{
"files": [
{
"pattern": "distribution/brew_pkg/bit-${currentVersion}-brew.tar.gz",
"target": "bit-brew/development/bit/${currentVersion}/"
}
]
}"""
server.upload(uploadSpec)
sh("./scripts/generate-formula.sh ${env.EXTERNAL_REPO}/bit-brew/development/bit/${currentVersion}/${brewTarName}")
sh("cd ./distribution && gsutil -m cp bit.rb ${uploadfolder}/bit-dev.rb")
stage 'notify release server'
notifyReleaseServer(currentVersion,releaseServer+"/update","${ArtifactRepo}/bit-brew/development/bit/${currentVersion}/${tarName}","brew")
slackSend channel: '#deployment', color: 'good', message: 'Mac: development - https://github.com/teambit/bit/blob/master/CHANGELOG.md'
}
catch (err) {
slackSend channel: '#deployment', color: 'error', message: "Mac: Failed to build bit-bin ${err}"
currentBuild.result = 'FAILURE'
}
}
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}"
sh ("${post}")
}