mirror of
https://github.com/status-im/status-go.git
synced 2025-02-18 01:37:22 +00:00
change Jenkinsfile to use parallel declarative format
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
134cce5b13
commit
d1847a3adc
165
_assets/ci/Jenkinsfile
vendored
165
_assets/ci/Jenkinsfile
vendored
@ -1,79 +1,100 @@
|
|||||||
#!/usr/bin/env groovy
|
pipeline {
|
||||||
|
agent { label 'linux' }
|
||||||
|
|
||||||
@NonCPS
|
parameters {
|
||||||
def getVersion(branch, sha, buildNumber) {
|
booleanParam(
|
||||||
version = branch.replaceAll(/\//, '-')
|
name: 'GITHUB_RELEASE',
|
||||||
|
description: 'Enable this to create a new GitHub release.',
|
||||||
|
defaultValue: false,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if (sha?.trim()) {
|
options {
|
||||||
version = version + '-g' + sha
|
disableConcurrentBuilds()
|
||||||
|
/* Go requires a certain directory structure */
|
||||||
|
checkoutToSubdirectory('src/github.com/status-im/status-go')
|
||||||
|
/* manage how many builds we keep */
|
||||||
|
buildDiscarder(logRotator(
|
||||||
|
numToKeepStr: '30',
|
||||||
|
daysToKeepStr: '30',
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
environment {
|
||||||
|
STATUS_PATH = 'src/github.com/status-im/status-go'
|
||||||
|
GOPATH = "${env.WORKSPACE}"
|
||||||
|
PATH = "${env.PATH}:${env.GOPATH}/bin"
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Prep') {
|
||||||
|
steps { script {
|
||||||
|
lib = load("${env.STATUS_PATH}/_assets/ci/lib.groovy")
|
||||||
|
println("Git Branch: ${lib.gitBranch()}")
|
||||||
|
println("Git Commit: ${lib.gitCommit()}")
|
||||||
|
} }
|
||||||
}
|
}
|
||||||
|
stage('Setup') { steps { dir(env.STATUS_PATH) {
|
||||||
if (buildNumber?.trim()) {
|
sh 'make setup'
|
||||||
version = version + '-' + buildNumber
|
} } }
|
||||||
}
|
stage('Lint') { steps { dir(env.STATUS_PATH) {
|
||||||
|
sh 'make ci'
|
||||||
return version
|
} } }
|
||||||
}
|
|
||||||
|
|
||||||
node('linux') {
|
|
||||||
checkout scm
|
|
||||||
|
|
||||||
def remoteOriginRegex = ~/^remotes\/origin\//
|
|
||||||
|
|
||||||
gitSHA = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
|
|
||||||
gitShortSHA = gitSHA.take(7)
|
|
||||||
gitBranch = sh(returnStdout: true, script: 'git name-rev --name-only HEAD').trim() - remoteOriginRegex
|
|
||||||
|
|
||||||
stage('Debug') {
|
|
||||||
sh 'env'
|
|
||||||
println(gitBranch)
|
|
||||||
println(gitSHA)
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Test') {
|
|
||||||
// TODO(adam): enable when unit tests start passing
|
|
||||||
//sh 'make ci'
|
|
||||||
sh 'make canary-test'
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Build') {
|
stage('Build') {
|
||||||
sh 'go get github.com/status-im/xgo'
|
parallel {
|
||||||
|
stage('Android') {
|
||||||
parallel (
|
stages {
|
||||||
'statusgo-android': {
|
stage('Compile') { steps { dir(env.STATUS_PATH) {
|
||||||
sh 'make statusgo-android'
|
sh 'make statusgo-android'
|
||||||
},
|
} } }
|
||||||
'statusgo-ios-simulator': {
|
stage('Archive') { steps {
|
||||||
sh '''
|
sh """
|
||||||
make statusgo-ios-simulator
|
mv ${env.STATUS_PATH}/build/bin/statusgo-android-16.aar \
|
||||||
cd build/bin/statusgo-ios-9.3-framework/
|
${env.WORKSPACE}/status-go-android-${lib.suffix()}.aar
|
||||||
zip -r status-go-ios.zip Statusgo.framework
|
"""
|
||||||
'''
|
archiveArtifacts("status-go-android-${lib.suffix()}.aar")
|
||||||
}
|
} }
|
||||||
)
|
stage('Upload') { steps { script {
|
||||||
|
lib.uploadArtifact("status-go-android-${lib.suffix()}.aar")
|
||||||
|
} } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('iOS') {
|
||||||
|
stages {
|
||||||
|
stage('Compile') { steps { dir(env.STATUS_PATH) {
|
||||||
|
sh 'make statusgo-ios-simulator'
|
||||||
|
dir('build/bin/statusgo-ios-9.3-framework') {
|
||||||
|
sh 'zip -r status-go-ios.zip Statusgo.framework'
|
||||||
|
}
|
||||||
|
} } }
|
||||||
|
stage('Archive') { steps {
|
||||||
|
sh """
|
||||||
|
mv ${env.STATUS_PATH}/build/bin/statusgo-ios-9.3-framework/status-go-ios.zip \
|
||||||
|
${env.WORKSPACE}/status-go-ios-${lib.suffix()}.zip
|
||||||
|
"""
|
||||||
|
archiveArtifacts("status-go-ios-${lib.suffix()}.zip")
|
||||||
|
} }
|
||||||
|
stage('Upload') { steps { script {
|
||||||
|
lib.uploadArtifact("status-go-ios-${lib.suffix()}.zip")
|
||||||
|
} } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
stage('Release') { when { expression { params.GITHUB_RELEASE == true } }
|
||||||
stage('Deploy') {
|
steps {
|
||||||
// For branch builds, replace the old artifact. For develop keep all of them.
|
def dst = lib.getReleaseDir()
|
||||||
def version = gitBranch == 'develop' ? getVersion(gitBranch, gitShortSHA, '') : getVersion(gitBranch, gitShortSHA, env.BUILD_ID)
|
sh 'make prepare-release'
|
||||||
def server = Artifactory.server 'artifactory'
|
withCredentials([[
|
||||||
def uploadSpec = """{
|
$class: 'UsernamePasswordMultiBinding',
|
||||||
"files": [
|
credentialsId: 'status-im-auto',
|
||||||
{
|
usernameVariable: 'GITHUB_USER',
|
||||||
"pattern": "build/bin/statusgo-android-16.aar",
|
passwordVariable: 'GITHUB_TOKEN'
|
||||||
"target": "libs-release-local/status-im/status-go/${version}/status-go-${version}.aar"
|
]]) {
|
||||||
},
|
sh "yes | make release release_branch=${gitBranch}"
|
||||||
{
|
}
|
||||||
"pattern": "build/bin/statusgo-ios-9.3-framework/status-go-ios.zip",
|
sh 'make clean-release'
|
||||||
"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)
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
48
_assets/ci/lib.groovy
Normal file
48
_assets/ci/lib.groovy
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
def gitCommit() {
|
||||||
|
return GIT_COMMIT.take(6)
|
||||||
|
}
|
||||||
|
|
||||||
|
def timestamp() {
|
||||||
|
def now = new Date(currentBuild.timeInMillis)
|
||||||
|
return now.format('yyMMdd-HHmmss', TimeZone.getTimeZone('UTC'))
|
||||||
|
}
|
||||||
|
|
||||||
|
def suffix() {
|
||||||
|
return "${gitCommit()}-${timestamp()}"
|
||||||
|
}
|
||||||
|
|
||||||
|
def gitBranch() {
|
||||||
|
return env.GIT_BRANCH.replace('origin/', '')
|
||||||
|
}
|
||||||
|
|
||||||
|
def getFilename(path) {
|
||||||
|
return path.tokenize('/')[-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
def getReleaseDir() {
|
||||||
|
return '/tmp/release-' + new File(env.WORKSPACE + '/VERSION').text.trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
def uploadArtifact(path) {
|
||||||
|
/* defaults for upload */
|
||||||
|
def domain = 'ams3.digitaloceanspaces.com'
|
||||||
|
def bucket = 'status-go'
|
||||||
|
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} \\
|
||||||
|
put ${path} s3://${bucket}/
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
return "https://${bucket}.${domain}/${getFilename(path)}"
|
||||||
|
}
|
||||||
|
|
||||||
|
return this
|
Loading…
x
Reference in New Issue
Block a user