forked from teambit/bit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile-brew
52 lines (38 loc) · 1.88 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
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"
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 tar')
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)
stage 'notify release server'
notifyReleaseServer(currentVersion,releaseServer+"/update","${ArtifactRepo}/bit-brew/development/bit/${currentVersion}/${tarName}","brew")
}
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}")
}