2017-09-21 18:38:25 +00:00
|
|
|
#!/usr/bin/env groovy
|
|
|
|
|
|
|
|
@NonCPS
|
|
|
|
def getVersion(branch, sha, buildNumber) {
|
|
|
|
version = branch.replaceAll(/\//, '-')
|
|
|
|
|
|
|
|
if (sha?.trim()) {
|
2017-09-25 16:06:13 +00:00
|
|
|
version = version + '-g' + sha
|
2017-09-21 18:38:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (buildNumber?.trim()) {
|
|
|
|
version = version + '-' + buildNumber
|
|
|
|
}
|
|
|
|
|
|
|
|
return version
|
|
|
|
}
|
|
|
|
|
|
|
|
node('linux') {
|
2017-11-29 06:48:40 +00:00
|
|
|
env.GOPATH = "${env.WORKSPACE}"
|
2018-04-05 13:14:47 +00:00
|
|
|
env.PATH = "${env.PATH}:${env.GOPATH}/bin"
|
2017-11-29 06:48:40 +00:00
|
|
|
|
|
|
|
cloneDir = 'src/github.com/status-im/status-go'
|
2017-09-21 18:38:25 +00:00
|
|
|
paramBranch = env.branch ? ('*/' + env.branch) : '*/develop'
|
|
|
|
|
2018-04-05 13:14:47 +00:00
|
|
|
dir(cloneDir) {
|
|
|
|
try {
|
|
|
|
deleteDir()
|
|
|
|
} catch (err) {
|
|
|
|
echo "failure while cleaning the directory"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-21 18:38:25 +00:00
|
|
|
checkout(
|
|
|
|
changelog: false,
|
2017-11-29 06:48:40 +00:00
|
|
|
poll: true,
|
2017-09-21 18:38:25 +00:00
|
|
|
scm: [$class: 'GitSCM', branches: [[name: paramBranch]],
|
|
|
|
doGenerateSubmoduleConfigurations: false,
|
2017-11-29 06:48:40 +00:00
|
|
|
extensions: [
|
|
|
|
[$class: 'RelativeTargetDirectory', relativeTargetDir: cloneDir]
|
|
|
|
],
|
2017-09-21 18:38:25 +00:00
|
|
|
submoduleCfg: [],
|
|
|
|
userRemoteConfigs: [[url: 'https://github.com/status-im/status-go']]]
|
|
|
|
)
|
|
|
|
|
|
|
|
def remoteOriginRegex = ~/^remotes\/origin\//
|
|
|
|
|
2017-11-29 06:48:40 +00:00
|
|
|
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
|
|
|
|
}
|
2017-09-21 18:38:25 +00:00
|
|
|
|
|
|
|
stage('Debug') {
|
|
|
|
sh 'env'
|
|
|
|
println(gitBranch)
|
|
|
|
println(gitSHA)
|
|
|
|
}
|
|
|
|
|
2017-11-29 06:48:40 +00:00
|
|
|
stage('Test') {
|
2018-04-05 13:14:47 +00:00
|
|
|
dir(cloneDir) {
|
|
|
|
sh 'make setup'
|
|
|
|
sh 'make ci'
|
|
|
|
}
|
2017-11-29 06:48:40 +00:00
|
|
|
}
|
2017-09-21 18:38:25 +00:00
|
|
|
|
|
|
|
stage('Build') {
|
|
|
|
sh 'go get github.com/karalabe/xgo'
|
|
|
|
|
|
|
|
parallel (
|
|
|
|
'statusgo-android': {
|
2017-11-29 06:48:40 +00:00
|
|
|
dir(cloneDir) {
|
|
|
|
sh 'make statusgo-android'
|
|
|
|
}
|
2017-09-21 18:38:25 +00:00
|
|
|
},
|
|
|
|
'statusgo-ios-simulator': {
|
2017-11-29 06:48:40 +00:00
|
|
|
dir(cloneDir) {
|
|
|
|
sh '''
|
|
|
|
make statusgo-ios-simulator
|
|
|
|
cd build/bin/statusgo-ios-9.3-framework/
|
|
|
|
zip -r status-go-ios.zip Statusgo.framework
|
|
|
|
'''
|
|
|
|
}
|
2017-09-21 18:38:25 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Deploy') {
|
2017-11-29 06:48:40 +00:00
|
|
|
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)
|
2017-12-05 08:35:12 +00:00
|
|
|
|
|
|
|
slackSend color: 'good', message: 'status-go `' + version + '` was built successfully. ' + env.BUILD_URL
|
2017-11-29 06:48:40 +00:00
|
|
|
}
|
2017-09-21 18:38:25 +00:00
|
|
|
}
|
|
|
|
}
|