status-go/Jenkinsfile-manual

106 lines
3.1 KiB
Groovy

#!/usr/bin/env groovy
@NonCPS
def getVersion(branch, sha, buildNumber) {
version = branch.replaceAll(/\//, '-')
if (sha?.trim()) {
version = version + '-g' + sha
}
if (buildNumber?.trim()) {
version = version + '-' + buildNumber
}
return version
}
node('linux') {
env.GOPATH = "${env.WORKSPACE}"
cloneDir = 'src/github.com/status-im/status-go'
paramBranch = env.branch ? ('*/' + env.branch) : '*/develop'
checkout(
changelog: false,
poll: true,
scm: [$class: 'GitSCM', branches: [[name: paramBranch]],
doGenerateSubmoduleConfigurations: false,
extensions: [
[$class: 'RelativeTargetDirectory', relativeTargetDir: cloneDir]
],
submoduleCfg: [],
userRemoteConfigs: [[url: 'https://github.com/status-im/status-go']]]
)
def remoteOriginRegex = ~/^remotes\/origin\//
dir(cloneDir) {
gitSHA = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
gitShortSHA = gitSHA.take(8)
gitBranch = sh(returnStdout: true, script: 'git name-rev --name-only HEAD').trim() - remoteOriginRegex
}
stage('Debug') {
sh 'env'
println(gitBranch)
println(gitSHA)
}
stage('Test') {
sh '''
make lint-install
make mock-install
make ci
'''
}
stage('Build') {
sh 'go get github.com/karalabe/xgo'
parallel (
'statusgo-android': {
dir(cloneDir) {
sh 'make statusgo-android'
}
},
'statusgo-ios-simulator': {
dir(cloneDir) {
sh '''
make statusgo-ios-simulator
cd build/bin/statusgo-ios-9.3-framework/
zip -r status-go-ios.zip Statusgo.framework
'''
}
}
)
}
stage('Deploy') {
dir(cloneDir) {
// For branch builds, replace the old artifact. For develop keep all of them.
def version = gitBranch == 'develop' ? getVersion(gitBranch, gitShortSHA, '') : getVersion(gitBranch, gitShortSHA, env.BUILD_ID)
def server = Artifactory.server 'artifacts'
def uploadSpec = """{
"files": [
{
"pattern": "build/bin/statusgo-android-16.aar",
"target": "libs-release-local/status-im/status-go/${version}/status-go-${version}.aar"
},
{
"pattern": "build/bin/statusgo-ios-9.3-framework/status-go-ios.zip",
"target": "libs-release-local/status-im/status-go-ios-simulator/${version}/status-go-ios-simulator-${version}.zip"
}
]
}"""
def buildInfo = Artifactory.newBuildInfo()
buildInfo.env.capture = false
buildInfo.name = 'status-go (' + gitBranch + '-' + gitShortSHA + ')'
server.upload(uploadSpec, buildInfo)
server.publishBuildInfo(buildInfo)
}
}
}