upload PR build artifacts to a separate bucket, also update desc

also splify syntax with helper methods and variables

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2018-10-02 16:40:36 -04:00
parent 4f9b2d91ea
commit 27667dd949
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
2 changed files with 47 additions and 17 deletions

View File

@ -17,7 +17,8 @@ pipeline {
println "Current JOB: ${env.JOB_NAME}" println "Current JOB: ${env.JOB_NAME}"
/* load common lib */ /* load common lib */
cmn = load('ci/common.groovy') cmn = load('ci/common.groovy')
/* just for a shorter access */
btype = cmn.getBuildType()
/* to avoid missing build tag parallel builds */ /* to avoid missing build tag parallel builds */
print "Build Number: ${cmn.tagBuild(true)}" print "Build Number: ${cmn.tagBuild(true)}"
} } } }
@ -25,20 +26,20 @@ pipeline {
stage('Build') { stage('Build') {
parallel { parallel {
stage('MacOS') { stage('MacOS') {
when { expression { cmn.getBuildType() != 'release' } } when { expression { btype != 'release' } }
steps { script { steps { script {
osx = cmn.buildBranch('status-react/combined/desktop-macos', cmn.getBuildType()) osx = cmn.buildBranch('status-react/combined/desktop-macos')
} } } } } }
stage('Linux') { stage('Linux') {
when { expression { cmn.getBuildType() != 'release' } } when { expression { btype != 'release' } }
steps { script { steps { script {
nix = cmn.buildBranch('status-react/combined/desktop-linux', cmn.getBuildType()) nix = cmn.buildBranch('status-react/combined/desktop-linux')
} } } } } }
stage('iOS') { steps { script { stage('iOS') { steps { script {
ios = cmn.buildBranch('status-react/combined/mobile-ios', cmn.getBuildType()) ios = cmn.buildBranch('status-react/combined/mobile-ios')
} } } } } }
stage('Android') { steps { script { stage('Android') { steps { script {
dro = cmn.buildBranch('status-react/combined/mobile-android', cmn.getBuildType()) dro = cmn.buildBranch('status-react/combined/mobile-android')
} } } } } }
stage('Android e2e') { steps { script { stage('Android e2e') { steps { script {
e2e = cmn.buildBranch('status-react/combined/mobile-android', 'e2e') e2e = cmn.buildBranch('status-react/combined/mobile-android', 'e2e')
@ -49,29 +50,38 @@ pipeline {
steps { script { steps { script {
sh('rm -f pkg/*') sh('rm -f pkg/*')
if (cmn.getBuildType() != 'release') { if (btype != 'release') {
cmn.copyArts('status-react/combined/desktop-macos', osx.number) cmn.copyArts('status-react/combined/desktop-macos', osx.number)
cmn.copyArts('status-react/combined/desktop-linux', nix.number) cmn.copyArts('status-react/combined/desktop-linux', nix.number)
} }
cmn.copyArts('status-react/combined/mobile-android', dro.number) cmn.copyArts('status-react/combined/mobile-android', dro.number)
cmn.copyArts('status-react/combined/mobile-android', e2e.number) cmn.copyArts('status-react/combined/mobile-android', e2e.number)
cmn.copyArts('status-react/combined/mobile-ios', ios.number)
archiveArtifacts('pkg/*') archiveArtifacts('pkg/*')
} } } }
} }
stage('Upload') { stage('Upload') {
steps { script { steps { script {
e2eUrl = cmn.uploadArtifact(findFiles(glob: 'pkg/*e2e.apk')[0].path) e2eUrl = cmn.uploadArtifact(cmn.pkgFind('e2e.apk'))
apkUrl = cmn.uploadArtifact(findFiles(glob: "pkg/*${cmn.getBuildType()}.apk")[0].path) apkUrl = cmn.uploadArtifact(cmn.pkgFind("${btype}.apk"))
if (cmn.getBuildType() != 'release') { if (btype != 'release') {
dmgUrl = cmn.uploadArtifact(findFiles(glob: 'pkg/*.dmg')[0].path) dmgUrl = cmn.uploadArtifact(cmn.pkgFind('dmg'))
appUrl = cmn.uploadArtifact(findFiles(glob: 'pkg/*.AppImage')[0].path) appUrl = cmn.uploadArtifact(cmn.pkgFind('AppImage'))
} else { } else {
dmgUrl = null dmgUrl = null
appUrl = null appUrl = null
} }
/* special case for iOS Diawi links */ /* special case for iOS Diawi links */
ipaUrl = ios.getBuildVariables().get('DIAWI_URL') ipaUrl = ios.getBuildVariables().get('DIAWI_URL')
/* add URLs to the build description */
cmn.setBuildDesc(
Apk: apkUrl,
e2e: e2eUrl,
iOS: ipaUrl,
App: appUrl,
Mac: dmgUrl
)
} } } }
} }
stage('Notify') { stage('Notify') {
@ -81,7 +91,7 @@ pipeline {
def message = ( def message = (
(env.CHANGE_ID != null ? (env.CHANGE_ID != null ?
"Build PR #${BRANCH_NAME}(${CHANGE_BRANCH}) success! " : "Build PR #${BRANCH_NAME}(${CHANGE_BRANCH}) success! " :
"Build ${cmn.getBuildType()} success! " "Build ${btype} success! "
)+ )+
"<${currentBuild.absoluteUrl}|${currentBuild.displayName}> "+ "<${currentBuild.absoluteUrl}|${currentBuild.displayName}> "+
"(${currentBuild.durationString})\n"+ "(${currentBuild.durationString})\n"+
@ -110,7 +120,7 @@ pipeline {
} }
stage('Publish') { stage('Publish') {
steps { script { steps { script {
switch (cmn.getBuildType()) { switch (btype) {
case 'nightly': case 'nightly':
build( build(
job: 'misc/status-im.github.io-update_env', job: 'misc/status-im.github.io-update_env',
@ -132,7 +142,7 @@ pipeline {
} } } }
} }
stage('Run e2e') { stage('Run e2e') {
when { expression { cmn.getBuildType() == 'nightly' } } when { expression { btype == 'nightly' } }
steps { script { steps { script {
e2eApk = e2e.getBuildVariables().get('SAUCE_URL') e2eApk = e2e.getBuildVariables().get('SAUCE_URL')
build( build(

View File

@ -16,7 +16,9 @@ def getBuildType() {
return params.BUILD_TYPE return params.BUILD_TYPE
} }
def buildBranch(name = null, buildType) { def buildBranch(name = null, buildType = null) {
/* default to current build type */
buildType = buildType ? buildType : getBuildType()
/* need to drop origin/ to match definitions of child jobs */ /* need to drop origin/ to match definitions of child jobs */
def branchName = env.GIT_BRANCH.replace('origin/', '') def branchName = env.GIT_BRANCH.replace('origin/', '')
/* always pass the BRANCH and BUILD_TYPE params with current branch */ /* always pass the BRANCH and BUILD_TYPE params with current branch */
@ -95,6 +97,10 @@ def uploadArtifact(path) {
/* defaults for upload */ /* defaults for upload */
def domain = 'ams3.digitaloceanspaces.com' def domain = 'ams3.digitaloceanspaces.com'
def bucket = 'status-im' def bucket = 'status-im'
/* There's so many PR builds we need a separate bucket */
if (getBuildType() == 'pr') {
bucket = 'status-im-prs'
}
withCredentials([usernamePassword( withCredentials([usernamePassword(
credentialsId: 'digital-ocean-access-keys', credentialsId: 'digital-ocean-access-keys',
usernameVariable: 'DO_ACCESS_KEY', usernameVariable: 'DO_ACCESS_KEY',
@ -154,6 +160,20 @@ def githubNotify(apkUrl, e2eUrl, ipaUrl, dmgUrl, appUrl, changeId) {
} }
} }
def pkgFind(glob) {
return findFiles(glob: "pkg/*${glob}")[0].path
}
def setBuildDesc(Map links) {
def desc = 'Links: \n'
links.each { type, url ->
if (url != null) {
desc += "<a href=\"${url}\">${type}</a> \n"
}
}
currentBuild.description = desc
}
def getParentRunEnv(name) { def getParentRunEnv(name) {
def c = currentBuild.rawBuild.getCause(hudson.model.Cause$UpstreamCause) def c = currentBuild.rawBuild.getCause(hudson.model.Cause$UpstreamCause)
if (c == null) { return null } if (c == null) { return null }