prepare Jenkinsfile.combined for PR builds

- add missing Lint step for mobile builds
- add missing upload steps for android
- prefix fastlane calls with bundle exec
- update slackSend to format for PR builds
- silence fastlane notifying slack, Jenkins already does

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2018-08-27 11:32:54 -04:00
parent 60b68758a8
commit 76e9501541
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
7 changed files with 51 additions and 34 deletions

View File

@ -32,6 +32,11 @@ pipeline {
}
}
}
stage('Lint') {
steps {
script { mobile.runLint() }
}
}
stage('Tests') {
steps {
script { mobile.runTests() }
@ -53,19 +58,25 @@ pipeline {
}
}
stage('Upload') {
when { expression { params.BUILD_TYPE == 'release' } }
steps {
script { mobile.android.uploadToPlayStore() }
script {
switch (params.BUILD_TYPE) {
case 'release':
mobile.android.uploadToPlayStore(); break;
case 'nightly':
env.DIAWI_URL = mobile.android.uploadToDiawi()
case 'e2e':
e2eApk = mobile.android.uploadToSauceLabs()
}
}
}
}
stage('Run e2e') {
when { expression { params.BUILD_TYPE == 'e2e' } }
steps { script {
mobile.android.uploadToDiawi()
apk = mobile.android.uploadToSauceLabs()
build(
job: 'end-to-end-tests/status-app-nightly', wait: false,
parameters: [string(name: 'apk', value: "--apk=${apk}")]
parameters: [string(name: 'apk', value: "--apk=${e2eApk}")]
)
} }
}

View File

@ -54,15 +54,18 @@ pipeline {
apkUrl = cmn.uploadArtifact(findFiles(glob: "pkg/*.${params.BUILD_TYPE}.apk")[0].path)
dmgUrl = cmn.uploadArtifact(findFiles(glob: 'pkg/*.dmg')[0].path)
appUrl = cmn.uploadArtifact(findFiles(glob: 'pkg/*.AppImage')[0].path)
/* special case for iOS Diawi link */
/* special case for iOS Diawi links */
ipaUrl = ios.getBuildVariables().get('DIAWI_URL')
} }
}
stage('Notify') {
steps {
steps { script {
slackSend(
message: (
"Build success! "+
(CHANGE_ID != null ?
"Build PR #${BRANCH_NAME}(${CHANGE_BRANCH}) success! " :
"Build ${params.BUILD_TYPE} success! "
)+
"<${currentBuild.absoluteUrl}|${currentBuild.displayName}> "+
"(${currentBuild.durationString})\n"+
(params.BUILD_TYPE == 'nightly' ?
@ -71,12 +74,15 @@ pipeline {
"(<${e2eUrl}|e2e>), "+
"<${ipaUrl}|iOS>, "+
"<${dmgUrl}|MacOS>, "+
"<${appUrl}|AppImage>"
: '')
"<${appUrl}|AppImage>" :
"Packages: "+
"<${dro.getBuildVariables().get('DIAWI_URL')}|Android>, "+
"<${ios.getBuildVariables().get('DIAWI_URL')}|iOS>"
)
),
color: 'good'
)
}
} }
}
stage('Publish') {
when { expression { params.BUILD_TYPE == 'nightly' } }

View File

@ -36,6 +36,11 @@ pipeline {
}
}
}
stage('Lint') {
steps {
script { mobile.runLint() }
}
}
stage('Tests') {
steps {
script { mobile.runTests() }

View File

@ -42,10 +42,8 @@ def uploadToSauceLabs() {
withCredentials([
string(credentialsId: 'SAUCE_ACCESS_KEY', variable: 'SAUCE_ACCESS_KEY'),
string(credentialsId: 'SAUCE_USERNAME', variable: 'SAUCE_USERNAME'),
string(credentialsId: 'GIT_HUB_TOKEN', variable: 'GITHUB_TOKEN'),
string(credentialsId: 'SLACK_JENKINS_WEBHOOK', variable: 'SLACK_URL')
]) {
sh 'fastlane android saucelabs'
sh 'bundle exec fastlane android saucelabs'
}
return env.SAUCE_LABS_APK
}
@ -53,14 +51,12 @@ def uploadToSauceLabs() {
def uploadToDiawi() {
env.SAUCE_LABS_APK = "im.status.ethereum-e2e-${GIT_COMMIT.take(6)}.apk"
withCredentials([
string(credentialsId: 'SAUCE_ACCESS_KEY', variable: 'SAUCE_ACCESS_KEY'),
string(credentialsId: 'SAUCE_USERNAME', variable: 'SAUCE_USERNAME'),
string(credentialsId: 'GIT_HUB_TOKEN', variable: 'GITHUB_TOKEN'),
string(credentialsId: 'SLACK_JENKINS_WEBHOOK', variable: 'SLACK_URL')
string(credentialsId: 'diawi-token', variable: 'DIAWI_TOKEN'),
]) {
sh 'fastlane android saucelabs'
sh 'bundle exec fastlane android upload_diawi'
}
return env.SAUCE_LABS_APK
diawiUrl = readFile "${env.WORKSPACE}/fastlane/diawi.out"
return diawiUrl
}
return this

View File

@ -18,7 +18,7 @@ def compile(type = 'nightly') {
string(credentialsId: 'APPLE_ID', variable: 'APPLE_ID'),
string(credentialsId: 'fastlane-match-password', variable:'MATCH_PASSWORD')
]) {
sh "fastlane ios ${target}"
sh "bundle exec fastlane ios ${target}"
}
def pkg = common.pkgFilename(type, 'ipa')
sh "cp status-adhoc/StatusIm.ipa ${pkg}"
@ -28,10 +28,8 @@ def compile(type = 'nightly') {
def uploadToDiawi() {
withCredentials([
string(credentialsId: 'diawi-token', variable: 'DIAWI_TOKEN'),
string(credentialsId: 'GIT_HUB_TOKEN', variable: 'GITHUB_TOKEN'),
string(credentialsId: 'SLACK_JENKINS_WEBHOOK', variable: 'SLACK_URL')
]) {
sh 'fastlane ios upload_diawi'
sh 'bundle exec fastlane ios upload_diawi'
}
diawiUrl = readFile "${env.WORKSPACE}/fastlane/diawi.out"
return diawiUrl

View File

@ -21,6 +21,10 @@ def prep(type = 'nightly') {
}
}
def runLint() {
sh 'lein cljfmt check'
}
def runTests() {
sh 'lein test-cljs'
}

View File

@ -93,7 +93,6 @@ def notify_about_new_build(source, url)
change_id = ENV["CHANGE_ID"]
unless change_id.nil?
github_api(
server_url: "https://api.github.com",
api_token: ENV["GITHUB_TOKEN"],
@ -103,19 +102,21 @@ def notify_about_new_build(source, url)
"body": msg
}
)
end
end
def upload_to_diawi_and_notify(source)
def upload_to_diawi(source)
diawi(
token: ENV["DIAWI_TOKEN"],
file: source
)
File.write("diawi.out", lane_context[SharedValues::UPLOADED_FILE_LINK_TO_DIAWI])
end
def upload_to_diawi_and_notify(source)
upload_to_diawi(source)
notify_about_new_build(
source,
@ -218,9 +219,7 @@ platform :ios do
desc "---"
desc "Output: writes `fastlane/diawi.out` file url of the uploded file"
lane :upload_diawi do
upload_to_diawi_and_notify(
"status-adhoc/StatusIm.ipa"
)
upload_to_diawi("status-adhoc/StatusIm.ipa")
end
desc "This fastlane step is a workaround!"
@ -284,9 +283,7 @@ platform :android do
desc "---"
desc "Output: writes `fastlane/diawi.out` file url of the uploded file"
lane :upload_diawi do
upload_to_diawi_and_notify(
"android/app/build/outputs/apk/release/app-release.apk"
)
upload_to_diawi("android/app/build/outputs/apk/release/app-release.apk")
end
desc "`fastlane android saucelabs` - upload .apk to sauce labs"