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 7
/
Jenkinsfile
109 lines (90 loc) · 4.37 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
109
/**
* IOS Jenkinsfile
*/
// In RHMAP's case, the following parameters are sent by RHMAP to the Jenkins job.
// This means, the Jenkins job has to be a parametrized build with those parameters.
CODE_SIGN_PROFILE_ID = params?.BUILD_CREDENTIAL_ID?.trim() // e.g. "redhat-dist-dp"
BUILD_CONFIG = params?.BUILD_CONFIG?.trim() // e.g. "Debug" or "Release"
// To hardcode the 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/saml-ios-swift
/* ------------- use these to hardcode values in Jenkinsfile ---------------- */
PROJECT_NAME = "saml-ios-swift"
INFO_PLIST = "saml-ios-swift/saml-ios-swift-Info.plist"
VERSION = "1.0.0"
SHORT_VERSION = "1.0"
BUNDLE_ID = "com.feedhenry.saml-ios-swift"
OUTPUT_FILE_NAME="${PROJECT_NAME}-${BUILD_CONFIG}.ipa"
SDK = "iphoneos"
XC_VERSION = "" // use something like 8.3 to use a specific XCode version.
// If this is not set, the default Xcode on the machine will be used
CLEAN = true // do a clean build and sign
/* ------------- use these to get values from Jenkins parametrized build ---------------- */
/*
PROJECT_NAME = params?.PROJECT_NAME?.trim() // e.g. "saml-ios-swift"
INFO_PLIST = params?.INFO_PLIST?.trim() // e.g. "saml-ios-swift/saml-ios-swift-Info.plist"
VERSION = params?.APP_VERSION?.trim() // e.g. "0.1-alpha"
SHORT_VERSION = params?.APP_SHORT_VERSION?.trim() // e.g. "0.1"
BUNDLE_ID = params?.BUNDLE_ID?.trim() // e.g. "com.feedhenry.saml-ios-swift"
OUTPUT_FILE_NAME = params?.OUTPUT_FILE_NAME?.trim() ?: "myapp.ipa" // if not set, myapp.ipa will be used
SDK = params?.OUTPUT_FILE_NAME?.trim() ?: "iphoneos" // if not set, "iphoneos" will be used
XC_VERSION = params?.XC_VERSION?.trim() ?: "" // use something like 8.3 to use a specific XCode version.
// if not set, the default Xcode on the machine will be used
CLEAN = params?.CLEAN?.trim()?.toBoolean() ?: true // default value is true
*/
/*
NOTE: RHMAP sends `BUILD_CONFIG` parameter to denote if it is a debug build or a release build.
However, from codesign/xcodebuild perspective, the steps required are the same.
So, we just ignore that parameter.
*/
// parametrized values
FH_CONFIG_CONTENT = params?.FH_CONFIG_CONTENT ?: ""
// RHMAP specific values. RHMAP currently sends build config type all lower case. we handle it here as case matters for Xcode.
// also, RHMAP can send "Distribution" config. we use "Release" in that case.
if(BUILD_CONFIG.toLowerCase() == "debug"){
BUILD_CONFIG = "Debug"
}
else if(BUILD_CONFIG.toLowerCase() == "release" || BUILD_CONFIG.toLowerCase() == "distribution"){
BUILD_CONFIG = "Release"
}
node('ios') {
stage('Checkout') {
checkout scm
}
stage('Prepare') {
writeFile file: "${PROJECT_NAME}/fhconfig.plist", text: FH_CONFIG_CONTENT
sh '/usr/local/bin/pod install'
}
stage('Build') {
withEnv(["XC_VERSION=${XC_VERSION}"]) {
xcodeBuild(
cleanBeforeBuild: CLEAN,
src: './',
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: "${BUILD_CONFIG}"
)
}
}
stage('CodeSign') {
codeSign(
profileId: "${CODE_SIGN_PROFILE_ID}",
clean: CLEAN,
verify: true,
ipaName: "${OUTPUT_FILE_NAME}",
appPath: "build/${BUILD_CONFIG}-${SDK}/${PROJECT_NAME}.app"
)
}
stage('Archive') {
archiveArtifacts "build/${BUILD_CONFIG}-${SDK}/${OUTPUT_FILE_NAME}"
}
}