2018-08-21 15:17:25 +00:00
|
|
|
def version() {
|
|
|
|
return readFile("${env.WORKSPACE}/VERSION").trim()
|
|
|
|
}
|
|
|
|
|
|
|
|
def buildBranch(name = null, buildType = params.BUILD_TYPE) {
|
|
|
|
/* always pass the BRANCH and BUILD_TYPE params with current branch */
|
|
|
|
return build(
|
|
|
|
job: name,
|
|
|
|
parameters: [
|
|
|
|
[name: 'BRANCH', value: env.GIT_BRANCH, $class: 'StringParameterValue'],
|
|
|
|
[name: 'BUILD_TYPE', value: buildType, $class: 'StringParameterValue'],
|
|
|
|
])
|
|
|
|
}
|
|
|
|
|
|
|
|
def copyArts(projectName, buildNo) {
|
|
|
|
copyArtifacts(
|
|
|
|
projectName: projectName,
|
|
|
|
target: 'pkg',
|
|
|
|
flatten: true,
|
|
|
|
selector: specific("${buildNo}")
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2018-08-14 18:09:52 +00:00
|
|
|
def installJSDeps(platform) {
|
|
|
|
def attempt = 1
|
|
|
|
def maxAttempts = 10
|
|
|
|
def installed = false
|
|
|
|
/* prepare environment for specific platform build */
|
|
|
|
sh "scripts/prepare-for-platform.sh ${platform}"
|
|
|
|
while (!installed && attempt <= maxAttempts) {
|
|
|
|
println "#${attempt} attempt to install npm deps"
|
|
|
|
sh 'npm install'
|
|
|
|
installed = fileExists('node_modules/web3/index.js')
|
|
|
|
attemp = attempt + 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def doGitRebase() {
|
|
|
|
try {
|
|
|
|
sh 'git rebase origin/develop'
|
|
|
|
} catch (e) {
|
|
|
|
sh 'git rebase --abort'
|
|
|
|
throw e
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-23 12:56:19 +00:00
|
|
|
def tagBuild(increment = false) {
|
|
|
|
def opts = (increment ? '--increment' : '')
|
2018-08-14 18:09:52 +00:00
|
|
|
withCredentials([[
|
|
|
|
$class: 'UsernamePasswordMultiBinding',
|
|
|
|
credentialsId: 'status-im-auto',
|
|
|
|
usernameVariable: 'GIT_USER',
|
|
|
|
passwordVariable: 'GIT_PASS'
|
|
|
|
]]) {
|
|
|
|
return sh(
|
|
|
|
returnStdout: true,
|
2018-08-23 12:56:19 +00:00
|
|
|
script: "./scripts/build_no.sh ${opts}"
|
2018-08-14 18:09:52 +00:00
|
|
|
).trim()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-23 12:56:19 +00:00
|
|
|
def getDirPath(path) {
|
|
|
|
return path.tokenize('/')[0..-2].join('/')
|
|
|
|
}
|
|
|
|
|
|
|
|
def getFilename(path) {
|
|
|
|
return path.tokenize('/')[-1]
|
|
|
|
}
|
|
|
|
|
|
|
|
def uploadArtifact(path) {
|
|
|
|
/* defaults for upload */
|
2018-08-14 18:09:52 +00:00
|
|
|
def domain = 'ams3.digitaloceanspaces.com'
|
2018-08-23 12:56:19 +00:00
|
|
|
def bucket = 'status-im'
|
2018-08-14 18:09:52 +00:00
|
|
|
withCredentials([usernamePassword(
|
|
|
|
credentialsId: 'digital-ocean-access-keys',
|
|
|
|
usernameVariable: 'DO_ACCESS_KEY',
|
|
|
|
passwordVariable: 'DO_SECRET_KEY'
|
|
|
|
)]) {
|
|
|
|
sh """
|
|
|
|
s3cmd \\
|
|
|
|
--acl-public \\
|
|
|
|
--host='${domain}' \\
|
|
|
|
--host-bucket='%(bucket)s.${domain}' \\
|
|
|
|
--access_key=${DO_ACCESS_KEY} \\
|
|
|
|
--secret_key=${DO_SECRET_KEY} \\
|
2018-08-23 12:56:19 +00:00
|
|
|
put ${path} s3://${bucket}/
|
2018-08-14 18:09:52 +00:00
|
|
|
"""
|
|
|
|
}
|
2018-08-23 12:56:19 +00:00
|
|
|
return "https://${bucket}.${domain}/${getFilename(path)}"
|
|
|
|
}
|
|
|
|
|
|
|
|
def timestamp() {
|
|
|
|
def now = new Date(currentBuild.timeInMillis)
|
|
|
|
return now.format('yyMMdd.HHmmss', TimeZone.getTimeZone('UTC'))
|
|
|
|
}
|
|
|
|
|
|
|
|
def gitCommit() {
|
|
|
|
return GIT_COMMIT.take(6)
|
|
|
|
}
|
|
|
|
|
|
|
|
def pkgFilename(type, ext) {
|
|
|
|
return "StatusIm.${timestamp()}.${gitCommit()}.${type}.${ext}"
|
2018-08-14 18:09:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return this
|