Update release Jenkinsfiles to use `cmn` library.

Jenkinsfile.upload_release_android
Jenkinsfile.upload_release_ios

Signed-off-by: Igor Mandrigin <i@mandrigin.ru>
This commit is contained in:
Igor Mandrigin 2018-09-21 13:57:06 +02:00 committed by Igor Mandrigin
parent 5f06ebc27d
commit cd83c7da6d
No known key found for this signature in database
GPG Key ID: 4A0EDDE26E66BC8B
5 changed files with 104 additions and 183 deletions

View File

@ -1,102 +1,54 @@
// We need release builds for users who want to test apps, diawi removes old builds and limits downloads, hence the need for Artifactory. pipeline {
// To see env: echo sh(returnStdout: true, script: 'env') agent { label 'linux' }
env.LANG="en_US.UTF-8" options {
env.LANGUAGE="en_US.UTF-8" buildDiscarder(logRotator(
env.LC_ALL="en_US.UTF-8" numToKeepStr: '60',
env.FASTLANE_DISABLE_COLORS=1 daysToKeepStr: '30',
env.REALM_DISABLE_ANALYTICS=1 artifactNumToKeepStr: '60',
))
}
def installJSDeps() { environment {
def attempt = 1 BUILD_PLATFORM = 'android'
def maxAttempts = 10 LANG = 'en_US.UTF-8'
def installed = false LANGUAGE = 'en_US.UTF-8'
while (!installed && attempt <= maxAttempts) { LC_ALL = 'en_US.UTF-8'
println "#${attempt} attempt to install npm deps" FASTLANE_DISABLE_COLORS = 1
sh 'npm install' REALM_DISABLE_ANALYTICS = 1
installed = fileExists('node_modules/web3/index.js') BUNDLE_PATH = "${HOME}/.bundle"
attemp = attempt + 1 ANDROID_HOME = '/usr/lib/android-sdk'
ANDROID_SDK_ROOT = '/usr/lib/android-sdk'
ANDROID_NDK = '/usr/lib/android-ndk'
ANDROID_NDK_HOME = '/usr/lib/android-ndk'
}
stages {
stage('Prep') {
steps { script {
/* Necessary to load methods */
mobile = load 'ci/mobile.groovy'
cmn = load 'ci/common.groovy'
mobile.prep('release')
} }
} }
} stage('Lint') {
steps { script { cmn.runLint() } }
timeout(90) {
node ('fastlane'){
def version
def build_no
load "$HOME/env.groovy"
try {
stage('Git & Dependencies') {
slackSend color: 'good', message: BRANCH_NAME + ' build started. ' + env.BUILD_URL
if (!BRANCH_NAME.startsWith("release/")){
error "Wrong branch name format: " + BRANCH_NAME + ", but it should be `release/version`"
}
checkout scm
sh 'git fetch --tags'
sh 'rm -rf node_modules'
sh 'cp .env.prod .env'
sh 'scripts/prepare-for-platform.sh mobile'
version = readFile("${env.WORKSPACE}/VERSION").trim()
installJSDeps()
sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack'
sh 'cd ios && pod install && cd ..'
}
stage('Tag Build') {
withCredentials([[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'status-im-auto',
usernameVariable: 'GIT_USER',
passwordVariable: 'GIT_PASS'
]]) {
build_no = sh(
returnStdout: true,
script: './scripts/build_no.sh --increment'
).trim()
}
}
stage('Tests') {
sh 'lein test-cljs'
}
stage('Build') {
sh 'lein prod-build'
}
stage('Build (Android)') {
sh 'cd android && ./gradlew react-native-android:installArchives && ./gradlew assembleRelease -PreleaseVersion=' + version
}
stage('Deploy (Android)') {
withCredentials([
string(
credentialsId: "SUPPLY_JSON_KEY_DATA",
variable: 'GOOGLE_PLAY_JSON_KEY'
),
string(
credentialsId: "SLACK_URL",
variable: 'SLACK_URL'
)
]) {
sh ('bundle exec fastlane android release')
}
}
} catch (e) {
slackSend color: 'bad', message: 'Release build failed uploading to the Play Market. ' + env.BUILD_URL
throw e
}
stage('Slack Notification') {
slackSend color: 'good', message: 'Release build ' + version + ' succesfully aploade to the Play Market'
}
} }
stage('Tests') {
steps { script { cmn.runTests() } }
}
stage('Build') {
steps { script { mobile.leinBuild('android') } }
}
stage('Compile') {
steps { script { apk = mobile.android.compile('release') } }
}
stage('Archive') {
steps { script { archiveArtifacts apk } }
}
stage('Upload') {
steps { script { mobile.android.uploadToPlayStore('release') } }
}
}
} }

View File

@ -1,91 +1,48 @@
// We need release builds for users who want to test apps, diawi removes old builds and limits downloads, hence the need for Artifactory. pipeline {
// To see env: echo sh(returnStdout: true, script: 'env') agent { label 'fastlane' }
env.LANG="en_US.UTF-8" options {
env.LANGUAGE="en_US.UTF-8" buildDiscarder(
env.LC_ALL="en_US.UTF-8" logRotator(
env.FASTLANE_DISABLE_COLORS=1 numToKeepStr: '30',
env.REALM_DISABLE_ANALYTICS=1 daysToKeepStr: '30',
artifactNumToKeepStr: '30',
def installJSDeps() { ))
def attempt = 1
def maxAttempts = 10
def installed = false
while (!installed && attempt <= maxAttempts) {
println "#${attempt} attempt to install npm deps"
sh 'npm install'
installed = fileExists('node_modules/web3/index.js')
attemp = attempt + 1
} }
}
timeout(90) { environment {
node ('fastlane'){ BUILD_PLATFORM = 'ios'
def version LANG = 'en_US.UTF-8'
def build_no LANGUAGE = 'en_US.UTF-8'
LC_ALL = 'en_US.UTF-8'
FASTLANE_DISABLE_COLORS=1
REALM_DISABLE_ANALYTICS=1
BUNDLE_PATH = "${HOME}/.bundle"
}
load "$HOME/env.groovy" stages {
stage('Prep') {
try { steps { script {
stage('Git & Dependencies') { if (!BRANCH_NAME.startsWith("release/")){
slackSend color: 'good', message: BRANCH_NAME + ' build started. ' + env.BUILD_URL error "Wrong branch name format: " + BRANCH_NAME + ", but it should be `release/<version>`"
}
if (!BRANCH_NAME.startsWith("release/")){ /* Necessary to load methods */
error "Wrong branch name format: " + BRANCH_NAME + ", but it should be `release/version`" mobile = load 'ci/mobile.groovy'
} cmn = load 'ci/common.groovy'
mobile.prep('release')
checkout scm } }
sh 'git fetch --tags'
sh 'rm -rf node_modules'
sh 'cp .env.prod .env'
sh 'scripts/prepare-for-platform.sh mobile'
version = readFile("${env.WORKSPACE}/VERSION").trim()
installJSDeps()
sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack'
sh 'cd ios && pod install && cd ..'
} }
stage('Lint') {
stage('Tag Build') { steps { script { cmn.runLint() } }
withCredentials([[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'status-im-auto',
usernameVariable: 'GIT_USER',
passwordVariable: 'GIT_PASS'
]]) {
build_no = sh(
returnStdout: true,
script: './scripts/build_no.sh --increment'
).trim()
}
} }
stage('Tests') { stage('Tests') {
sh 'lein test-cljs' steps { script { cmn.runTests() } }
} }
stage('Build') { stage('Build') {
sh 'lein prod-build' steps { script { mobile.leinBuild('ios') } }
} }
stage('Compile') {
stage('Build & TestFlight (iOS)') { steps { script { api = mobile.ios.compile('testflight') } }
withCredentials([
string(credentialsId: "slave-pass-${env.NODE_NAME}", variable: 'KEYCHAIN_PASSWORD'),
string(credentialsId: "SLACK_URL", variable: 'SLACK_URL'),
string(credentialsId: 'FASTLANE_PASSWORD', variable: 'FASTLANE_PASSWORD'),
string(credentialsId: 'APPLE_ID', variable: 'APPLE_ID'),
string(credentialsId: 'fastlane-match-password', variable:'MATCH_PASSWORD')]) {
sh "plutil -replace CFBundleShortVersionString -string ${version} ios/StatusIm/Info.plist"
sh "plutil -replace CFBundleVersion -string ${build_no} ios/StatusIm/Info.plist"
sh 'fastlane ios release'
}
} }
stage('Slack Notification') {
slackSend color: 'good', message: 'Release build ' + version + ' succesfully aploade to iTunes Connect'
}
} }
} }

View File

@ -14,12 +14,12 @@ def compile(type = 'nightly') {
return pkg return pkg
} }
def uploadToPlayStore() { def uploadToPlayStore(type = 'nightly') {
withCredentials([ withCredentials([
string(credentialsId: "SUPPLY_JSON_KEY_DATA", variable: 'GOOGLE_PLAY_JSON_KEY'), string(credentialsId: "SUPPLY_JSON_KEY_DATA", variable: 'GOOGLE_PLAY_JSON_KEY'),
string(credentialsId: "SLACK_URL", variable: 'SLACK_URL') string(credentialsId: "SLACK_URL", variable: 'SLACK_URL')
]) { ]) {
sh 'bundle exec fastlane android nightly' sh "bundle exec fastlane android ${type}"
} }
} }

View File

@ -5,7 +5,16 @@ def plutil(name, value) {
} }
def compile(type = 'nightly') { def compile(type = 'nightly') {
def target = (type == 'release' ? 'adhoc' : 'nightly') def target = 'nightly'
if (type == 'release') {
target = 'adhoc'
}
if (type == 'testflight') {
target = 'release'
}
/* configure build metadata */ /* configure build metadata */
plutil('CFBundleShortVersionString', common.version()) plutil('CFBundleShortVersionString', common.version())
plutil('CFBundleVersion', common.tagBuild()) plutil('CFBundleVersion', common.tagBuild())
@ -20,9 +29,12 @@ def compile(type = 'nightly') {
]) { ]) {
sh "bundle exec fastlane ios ${target}" sh "bundle exec fastlane ios ${target}"
} }
def pkg = common.pkgFilename(type, 'ipa') if (type != 'testflight') {
sh "cp status-adhoc/StatusIm.ipa ${pkg}" def pkg = common.pkgFilename(type, 'ipa')
return pkg sh "cp status-adhoc/StatusIm.ipa ${pkg}"
return pkg
}
return ''
} }
def uploadToDiawi() { def uploadToDiawi() {

View File

@ -5,12 +5,12 @@
# #
# https://docs.fastlane.tools/actions # https://docs.fastlane.tools/actions
# #
# Fastlane is updated quite frequently with security patches
# update_fastlane
# There are a few env variables defined in the .env file in # There are a few env variables defined in the .env file in
# this directory (fastlane/.env) # this directory (fastlane/.env)
# Fastlane is updated quite frequently with security patches
update_fastlane
# unlocks keychain if KEYCHAIN_PASSWORD variable is present # unlocks keychain if KEYCHAIN_PASSWORD variable is present
# (to be used on CI machines) # (to be used on CI machines)