This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Jenkinsfile
108 lines (99 loc) · 4.25 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/**
* Cordova Jenkinsfile
*/
// in RHMAP's case, the following parameters are sent by RHMAP to Jenkins job.
// this means, the Jenkins job must be a parametrized build with those parameters.
def platform = params?.PLATFORM?.trim() // e.g. "ios" or "android"
BUILD_CONFIG = params?.BUILD_CONFIG?.trim() // e.g. "Debug" or "Release"
CODE_SIGN_PROFILE_ID = params?.BUILD_CREDENTIAL_ID?.trim() // e.g. "redhat-dist-dp"
// To hardcode values uncomment the lines below
//CODE_SIGN_PROFILE_ID = "redhat-dist-dp"
//BUILD_CONFIG = "debug"
// sample values commented below are for https://github.com/feedhenry-templates/helloworld-app
/* ------------- use these to hardcode values in Jenkinsfile ---------------- */
PROJECT_NAME = "Helloworld"
CLEAN = true // Do a clean build and sign
INFO_PLIST = "Helloworld/Helloworld-Info.plist"
VERSION = "1.0.0"
SHORT_VERSION = "1.0"
BUNDLE_ID = "org.feedhenry.dart.helloworld.cordova"
OUTPUT_FILE_NAME="${PROJECT_NAME}-${BUILD_CONFIG}.ipa".replace(" ", "").toLowerCase()
SDK = "iphoneos"
if (BUILD_CONFIG.toLowerCase() == "debug") {
OSX_BUILD_CONFIG = "Debug"
} else if(BUILD_CONFIG.toLowerCase() == "release" || BUILD_CONFIG.toLowerCase() == "distribution") {
OSX_BUILD_CONFIG = "Release"
}
node(platform) {
stage("Checkout") {
checkout scm
}
stage("Prepare") {
writeFile file: 'www/fhconfig.json', text: params.FH_CONFIG_CONTENT
sh 'npm install --production'
sh "cordova platform rm ${platform}"
sh "cordova platform add ${platform}"
sh "cordova prepare ${platform}"
sh 'rm -rf node_modules'
}
stage("Build") {
if (platform == 'android') {
if (BUILD_CONFIG == 'debug') {
sh "cordova build ${platform} --debug"
} else {
sh "cordova build ${platform} --release"
}
} else {
xcodeBuild(
cleanBeforeBuild: CLEAN,
src: "./platforms/${platform}",
schema: "${PROJECT_NAME}",
workspace: "${PROJECT_NAME}",
buildDir: "build",
sdk: "${SDK}",
version: "${VERSION}",
shortVersion: "${SHORT_VERSION}",
bundleId: "${BUNDLE_ID}",
infoPlistPath: "${INFO_PLIST}",
xcodeBuildArgs: 'ENABLE_BITCODE=NO OTHER_CFLAGS="-fstack-protector -fstack-protector-all"',
autoSign: false,
config: "${OSX_BUILD_CONFIG}"
)
}
}
stage("Sign") {
if (platform == 'android') {
if (BUILD_CONFIG == 'release') {
signAndroidApks (
keyStoreId: "${params.BUILD_CREDENTIAL_ID}",
keyAlias: "${params.BUILD_CREDENTIAL_ALIAS}",
apksToSign: "platforms/android/**/*-unsigned.apk",
// uncomment the following line to output the signed APK to a separate directory as described above
// signedApkMapping: [ $class: UnsignedApkBuilderDirMapping ],
// uncomment the following line to output the signed APK as a sibling of the unsigned APK, as described above, or just omit signedApkMapping
// you can override these within the script if necessary
// androidHome: '/usr/local/Cellar/android-sdk'
)
} else {
println('Debug Build - Using default developer signing key')
}
}
if (platform == 'ios') {
codeSign(
profileId: "${CODE_SIGN_PROFILE_ID}",
clean: CLEAN,
verify: true,
ipaName: OUTPUT_FILE_NAME,
appPath: "platforms/ios/build/${OSX_BUILD_CONFIG}-${SDK}/${PROJECT_NAME}.app"
)
}
}
stage("Archive") {
if (platform == 'android') {
archiveArtifacts artifacts: "platforms/android/build/outputs/apk/android-${BUILD_CONFIG}.apk", excludes: 'platforms/android/build/outputs/apk/*-unaligned.apk'
}
if (platform == 'ios') {
archiveArtifacts artifacts: "platforms/${platform}/build/${OSX_BUILD_CONFIG}-${SDK}/${OUTPUT_FILE_NAME}"
}
}
}