Skip to content

Commit 5fb33cc

Browse files
committed
split groovy scripts more, use job parameters
Signed-off-by: Jakub Sokołowski <[email protected]>
1 parent 68e4be9 commit 5fb33cc

File tree

10 files changed

+211
-185
lines changed

10 files changed

+211
-185
lines changed

ci/Jenkinsfile.android

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pipeline {
55
buildDiscarder(logRotator(
66
numToKeepStr: '10',
77
daysToKeepStr: '30',
8-
artifactNumToKeepStr: '4',
8+
artifactNumToKeepStr: '6',
99
))
1010
}
1111

@@ -25,9 +25,10 @@ pipeline {
2525
stage('Prep') {
2626
steps {
2727
script {
28+
print "Running ${params.BUILD_TYPE} build!"
2829
/* Necessary to load methods */
2930
mobile = load 'ci/mobile.groovy'
30-
mobile.prepDeps()
31+
mobile.prep(type: params.BUILD_TYPE)
3132
}
3233
}
3334
}
@@ -43,25 +44,25 @@ pipeline {
4344
}
4445
stage('Compile') {
4546
steps {
46-
script { apk = mobile.compileAndroid(e2e: params.RUN_E2E) }
47+
script { apk = mobile.android.compile(type: params.BUILD_TYPE) }
4748
}
4849
}
49-
stage('Bundle') {
50-
when { expression { !params.RUN_E2E } }
50+
stage('Archive') {
5151
steps {
52-
script { mobile.bundleAndroid() }
52+
script { archiveArtifacts apk }
5353
}
5454
}
55-
stage('Archive') {
56-
when { expression { !params.RUN_E2E } }
55+
stage('Upload') {
56+
when { expression { params.BUILD_TYPE == 'release' } }
5757
steps {
58-
script { archiveArtifacts apk }
58+
script { mobile.android.uploadToPlayStore() }
5959
}
6060
}
6161
stage('Run e2e') {
62-
when { expression { params.RUN_E2E } }
62+
when { expression { params.BUILD_TYPE == 'e2e' } }
6363
steps { script {
64-
apk = mobile.uploadSauceLabs()
64+
mobile.android.uploadToDiawi()
65+
apk = mobile.android.uploadToSauceLabs()
6566
build(
6667
job: 'end-to-end-tests/status-app-nightly', wait: false,
6768
parameters: [string(name: 'apk', value: "--apk=${apk}")]

ci/Jenkinsfile.combined

Lines changed: 33 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -14,69 +14,49 @@ pipeline {
1414
stage('Tag') {
1515
steps { script {
1616
common = load('ci/common.groovy')
17-
/* to avoid race conditions in parallel builds */
17+
/* to avoid missing build tag parallel builds */
1818
print "Build Number: ${common.tagBuild()}"
1919
} }
2020
}
2121
stage('Build') {
2222
parallel {
23-
stage('MacOS') {
24-
steps { script {
25-
osx = build('status-react/combined/desktop-macos')
26-
} }
27-
}
28-
stage('Linux') {
29-
steps { script {
30-
nix = build('status-react/combined/desktop-linux')
31-
} }
32-
}
33-
stage('iOS') {
34-
steps { script {
35-
ios = build('status-react/combined/mobile-ios')
36-
} }
37-
}
38-
stage('Android') {
39-
steps { script {
40-
dro = build('status-react/combined/mobile-android')
41-
} }
42-
}
43-
stage('Android e2e') {
44-
steps {
45-
build('status-react/combined/mobile-android-e2e')
46-
}
47-
}
23+
stage('MacOS') { steps { script {
24+
osx = common.buildBranch('status-react/combined/desktop-macos')
25+
} } }
26+
stage('Linux') { steps { script {
27+
nix = common.buildBranch('status-react/combined/desktop-linux')
28+
} } }
29+
stage('iOS') { steps { script {
30+
ios = common.buildBranch('status-react/combined/mobile-ios')
31+
} } }
32+
stage('Android') { steps { script {
33+
dro = common.buildBranch('status-react/combined/mobile-android')
34+
} } }
35+
stage('Android e2e') { steps { script {
36+
e2e = common.buildBranch('status-react/combined/mobile-android', 'e2e')
37+
} } }
4838
}
4939
}
5040
stage('Archive') {
51-
steps {
41+
steps { script {
5242
sh('rm -f pkg/*')
53-
copyArtifacts(
54-
projectName: 'status-react/combined/mobile-ios', target: 'pkg',
55-
flatten: true, selector: specific("${ios.number}")
56-
)
57-
copyArtifacts(
58-
projectName: 'status-react/combined/mobile-android', target: 'pkg',
59-
flatten: true, selector: specific("${dro.number}")
60-
)
61-
copyArtifacts(
62-
projectName: 'status-react/combined/desktop-macos', target: 'pkg',
63-
flatten: true, selector: specific("${osx.number}")
64-
)
65-
copyArtifacts(
66-
projectName: 'status-react/combined/desktop-linux', target: 'pkg',
67-
flatten: true, selector: specific("${nix.number}")
68-
)
43+
common.copyArts('status-react/combined/desktop-macos', osx.number)
44+
common.copyArts('status-react/combined/desktop-linux', nix.number)
45+
common.copyArts('status-react/combined/mobile-android', dro.number)
46+
common.copyArts('status-react/combined/mobile-android', e2e.number)
6947
archiveArtifacts('pkg/*')
70-
}
48+
} }
7149
}
7250
stage('Upload') {
73-
when { expression { params.PUBLISH } }
51+
when { expression { params.BUILD_TYPE == 'nightly' } }
7452
steps { script {
75-
def pkg = "StatusIm-${GIT_COMMIT.take(6)}"
76-
apkUrl = common.uploadArtifact('pkg', "${pkg}.apk")
77-
ipaUrl = common.uploadArtifact('pkg', "${pkg}.ipa")
78-
dmgUrl = common.uploadArtifact('pkg', "${pkg}.dmg")
79-
appUrl = common.uploadArtifact('pkg', "${pkg}.AppImage")
53+
def pkg = "pkg/StatusIm-${GIT_COMMIT.take(6)}"
54+
e2eUrl = common.uploadArtifact("${pkg}-e2e.apk")
55+
apkUrl = common.uploadArtifact("${pkg}.apk")
56+
dmgUrl = common.uploadArtifact("${pkg}.dmg")
57+
appUrl = common.uploadArtifact("${pkg}.AppImage")
58+
/* special case for iOS Diawi link */
59+
ipaUrl = ios.getEnvironment().DIAWI_URL
8060
} }
8161
}
8262
stage('Notify') {
@@ -86,7 +66,8 @@ pipeline {
8666
"Build success! "+
8767
"<${currentBuild.absoluteUrl}|${currentBuild.displayName}> "+
8868
"(${currentBuild.durationString})\n"+
89-
(params.PUBLISH ?
69+
(params.BUILD_TYPE == 'nightly' ?
70+
"E2E: ${e2eUrl}\n"+
9071
"APK: ${apkUrl}\n"+
9172
"IPA: ${ipaUrl}\n"+
9273
"DMG: ${dmgUrl}\n"+
@@ -98,7 +79,7 @@ pipeline {
9879
}
9980
}
10081
stage('Publish') {
101-
when { expression { params.PUBLISH } }
82+
when { expression { params.BUILD_TYPE == 'nightly' } }
10283
steps {
10384
build(
10485
job: 'misc/status-im.github.io-update_env',

ci/Jenkinsfile.ios

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ pipeline {
2929
stage('Prep') {
3030
steps {
3131
script {
32+
print "Running ${params.BUILD_TYPE} build!"
3233
/* Necessary to load methods */
3334
mobile = load 'ci/mobile.groovy'
34-
mobile.prepDeps()
35+
mobile.prep(type: params.BUILD_TYPE)
3536
}
3637
}
3738
}
@@ -47,7 +48,7 @@ pipeline {
4748
}
4849
stage('Compile') {
4950
steps {
50-
script { api = mobile.compileiOS() }
51+
script { api = mobile.ios.compile(type: params.BUILD_TYPE) }
5152
}
5253
}
5354
stage('Archive') {
@@ -56,9 +57,8 @@ pipeline {
5657
}
5758
}
5859
stage('Upload') {
59-
when { expression { params.RUN_E2E } }
6060
steps {
61-
script { env.DIAWI_URL = uploadiOS() }
61+
script { env.DIAWI_URL = mobile.ios.uploadToDiawi() }
6262
}
6363
}
6464
}

ci/android.groovy

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
common = load 'ci/common.groovy'
2+
3+
def uploadArtifact() {
4+
def artifact_dir = pwd() + '/android/app/build/outputs/apk/release/'
5+
println (artifact_dir + 'app-release.apk')
6+
def artifact = (artifact_dir + 'app-release.apk')
7+
def server = Artifactory.server('artifacts')
8+
def filename = "im.status.ethereum-${GIT_COMMIT.take(6)}-n-fl.apk"
9+
def newArtifact = (artifact_dir + filename)
10+
sh "cp ${artifact} ${newArtifact}"
11+
def uploadSpec = '{ "files": [ { "pattern": "*apk/release/' + filename + '", "target": "nightlies-local" }]}'
12+
def buildInfo = server.upload(uploadSpec)
13+
return 'http://artifacts.status.im:8081/artifactory/nightlies-local/' + filename
14+
}
15+
16+
def compile(type = 'nightly') {
17+
common.tagBuild()
18+
def gradleOpt = ''
19+
if (type == 'release') {
20+
gradleOpt = "-PreleaseVersion=${common.version()}"
21+
}
22+
dir('android') {
23+
sh './gradlew react-native-android:installArchives'
24+
sh "./gradlew assembleRelease ${gradleOpt}"
25+
}
26+
def pkg = "StatusIm-${GIT_COMMIT.take(6)}${(type = 'e2e' ?: '-e2e')}.apk"
27+
sh "cp android/app/build/outputs/apk/release/app-release.apk ${pkg}"
28+
return pkg
29+
}
30+
31+
def uploadToPlayStore() {
32+
withCredentials([
33+
string(credentialsId: "SUPPLY_JSON_KEY_DATA", variable: 'GOOGLE_PLAY_JSON_KEY'),
34+
string(credentialsId: "SLACK_URL", variable: 'SLACK_URL')
35+
]) {
36+
sh 'bundle exec fastlane android nightly'
37+
}
38+
}
39+
40+
def uploadToSauceLabs() {
41+
env.SAUCE_LABS_APK = "im.status.ethereum-e2e-${GIT_COMMIT.take(6)}.apk"
42+
withCredentials([
43+
string(credentialsId: 'SAUCE_ACCESS_KEY', variable: 'SAUCE_ACCESS_KEY'),
44+
string(credentialsId: 'SAUCE_USERNAME', variable: 'SAUCE_USERNAME'),
45+
string(credentialsId: 'GIT_HUB_TOKEN', variable: 'GITHUB_TOKEN'),
46+
string(credentialsId: 'SLACK_JENKINS_WEBHOOK', variable: 'SLACK_URL')
47+
]) {
48+
sh 'fastlane android saucelabs'
49+
}
50+
return env.SAUCE_LABS_APK
51+
}
52+
53+
def uploadToDiawi() {
54+
env.SAUCE_LABS_APK = "im.status.ethereum-e2e-${GIT_COMMIT.take(6)}.apk"
55+
withCredentials([
56+
string(credentialsId: 'SAUCE_ACCESS_KEY', variable: 'SAUCE_ACCESS_KEY'),
57+
string(credentialsId: 'SAUCE_USERNAME', variable: 'SAUCE_USERNAME'),
58+
string(credentialsId: 'GIT_HUB_TOKEN', variable: 'GITHUB_TOKEN'),
59+
string(credentialsId: 'SLACK_JENKINS_WEBHOOK', variable: 'SLACK_URL')
60+
]) {
61+
sh 'fastlane android saucelabs'
62+
}
63+
return env.SAUCE_LABS_APK
64+
}
65+
66+
return this

ci/common.groovy

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
def version() {
2+
return readFile("${env.WORKSPACE}/VERSION").trim()
3+
}
4+
5+
def buildBranch(name = null, buildType = params.BUILD_TYPE) {
6+
/* always pass the BRANCH and BUILD_TYPE params with current branch */
7+
return build(
8+
job: name,
9+
parameters: [
10+
[name: 'BRANCH', value: env.GIT_BRANCH, $class: 'StringParameterValue'],
11+
[name: 'BUILD_TYPE', value: buildType, $class: 'StringParameterValue'],
12+
])
13+
}
14+
15+
def copyArts(projectName, buildNo) {
16+
copyArtifacts(
17+
projectName: projectName,
18+
target: 'pkg',
19+
flatten: true,
20+
selector: specific("${buildNo}")
21+
)
22+
}
23+
124
def installJSDeps(platform) {
225
def attempt = 1
326
def maxAttempts = 10

ci/desktop.groovy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ external_modules_dir = [
1313
'modules/react-native-status/desktop',
1414
]
1515

16+
external_fonts = [
17+
'../../../../../resources/fonts/SF-Pro-Text-Regular.otf',
18+
'../../../../../resources/fonts/SF-Pro-Text-Medium.otf',
19+
'../../../../../resources/fonts/SF-Pro-Text-Light.otf',
20+
]
21+
1622
def cleanupBuild() {
1723
sh """
1824
rm -rf \\
@@ -88,6 +94,7 @@ def compileLinux() {
8894
cmake -Wno-dev \\
8995
-DCMAKE_BUILD_TYPE=Release \\
9096
-DEXTERNAL_MODULES_DIR='${external_modules_dir.join(";")}' \\
97+
-DDESKTOP_FONTS='${external_fonts.join(";")}' \\
9198
-DJS_BUNDLE_PATH='${workspace}/${packageFolder}/StatusIm.jsbundle' \\
9299
-DCMAKE_CXX_FLAGS:='-DBUILD_FOR_BUNDLE=1'
93100
"""
@@ -154,6 +161,7 @@ def compileMacOS() {
154161
cmake -Wno-dev \\
155162
-DCMAKE_BUILD_TYPE=Release \\
156163
-DEXTERNAL_MODULES_DIR='${external_modules_dir.join(";")}' \\
164+
-DDESKTOP_FONTS='${external_fonts.join(";")}' \\
157165
-DJS_BUNDLE_PATH='${workspace}/${packageFolder}/StatusIm.jsbundle' \\
158166
-DCMAKE_CXX_FLAGS:='-DBUILD_FOR_BUNDLE=1'
159167
"""

ci/ios.groovy

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
def compile(type = 'nightly') {
2+
def target = (type == 'release' ? 'adhoc' : 'nightly')
3+
withCredentials([
4+
string(credentialsId: 'SLACK_URL', variable: 'SLACK_URL'),
5+
string(credentialsId: "slave-pass-${env.NODE_NAME}", variable: 'KEYCHAIN_PASSWORD'),
6+
string(credentialsId: 'FASTLANE_PASSWORD', variable: 'FASTLANE_PASSWORD'),
7+
string(credentialsId: 'APPLE_ID', variable: 'APPLE_ID'),
8+
string(credentialsId: 'fastlane-match-password', variable:'MATCH_PASSWORD')
9+
]) {
10+
sh "plutil -replace CFBundleShortVersionString -string ${common.version()} ios/StatusIm/Info.plist"
11+
sh "plutil -replace CFBundleVersion -string ${common.tagBuild()} ios/StatusIm/Info.plist"
12+
sh "fastlane ios ${target}"
13+
}
14+
def pkg = "StatusIm-${GIT_COMMIT.take(6)}.ipa"
15+
sh "cp status-adhoc/StatusIm.ipa ${pkg}"
16+
return pkg
17+
}
18+
19+
def uploadToDiawi() {
20+
withCredentials([
21+
string(credentialsId: 'diawi-token', variable: 'DIAWI_TOKEN'),
22+
string(credentialsId: 'GIT_HUB_TOKEN', variable: 'GITHUB_TOKEN'),
23+
string(credentialsId: 'SLACK_JENKINS_WEBHOOK', variable: 'SLACK_URL')
24+
]) {
25+
sh 'fastlane ios upload_diawi'
26+
}
27+
diawiUrl = readFile "${env.WORKSPACE}/fastlane/diawi.out"
28+
return diawiUrl
29+
}
30+
31+
return this

0 commit comments

Comments
 (0)