首先,我是Jenkins的新手,试图弄清楚在我采用该方法之前所做的事情。考虑如何改善现有管道。
我有一个iOS项目,其中有4个不同的构建目标,每个目标都有不同的配置文件。在我的jenkinsfile中,我有一个包含几个阶段的管道,我也有一个指向我的exportOptions.plist的定义路径,该路径具有所有配置概要文件ID。
exportOptions.plist在创建4个不同IPA的阶段中使用,它作为选项传递给4行中的每行上的-exportOptionsPlist;
在创建存档的阶段之前,我必须在4行中的每行上对诸如PROVISIONING_PROFILE之类的参数进行硬编码;
是否可以从exportOptions.plist中获取PROVISIONING_PROFILE字符串?
stage('create arch') {
steps {
script {
if (BRANCH_NAME == 'dev') {
sh '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project myApp/myApp.xcodeproj -scheme myApp_DEV -configuration Distribution -archivePath ' + XCARCHIVE_PATH_1 + ' TARGETED_DEVICE_FAMILY="1,2" CODE_SIGN_IDENTITY="iPhone Distribution: myCompany" PROVISIONING_PROFILE="1234567890" archive'
}
if (BRANCH_NAME == 'release') {
sh '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project myApp/myApp.xcodeproj -scheme myApp_1 -configuration Distribution -archivePath ' + XCARCHIVE_PATH + ' TARGETED_DEVICE_FAMILY="1,2" CODE_SIGN_IDENTITY="iPhone Distribution: myCompany" PROVISIONING_PROFILE="0987654321" archive'
sh '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project myApp/myApp.xcodeproj -scheme myApp_DEV -configuration Distribution -archivePath ' + XCARCHIVE_PATH_1 + ' TARGETED_DEVICE_FAMILY="1,2" CODE_SIGN_IDENTITY="iPhone Distribution: myCompany" PROVISIONING_PROFILE="1234567890" archive'
sh '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project myApp/myApp.xcodeproj -scheme myApp_2 -configuration Distribution -archivePath ' + XCARCHIVE_PATH_2 + ' TARGETED_DEVICE_FAMILY="1,2" CODE_SIGN_IDENTITY="iPhone Distribution: myCompany" PROVISIONING_PROFILE="0987612345" archive'
sh '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project myApp/myApp.xcodeproj -scheme myApp_3 -configuration Distribution -archivePath ' + XCARCHIVE_PATH_3 + ' TARGETED_DEVICE_FAMILY="1,2" CODE_SIGN_IDENTITY="iPhone Distribution: myCompany" PROVISIONING_PROFILE="5432109876" archive'
}
}
}
}
stage('create ipa') {
steps {
script {
if (BRANCH_NAME == 'dev') {
sh '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -exportArchive -archivePath ' + XCARCHIVE_PATH_1 + ' -exportPath ' + TARGET_IPA_PATH + ' -exportOptionsPlist ' + EXPORT_OPTIONS_PLIST_PATH
}
if (BRANCH_NAME == 'release') {
sh '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -exportArchive -archivePath ' + XCARCHIVE_PATH + ' -exportPath ' + TARGET_IPA_PATH + ' -exportOptionsPlist ' + EXPORT_OPTIONS_PLIST_PATH
sh '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -exportArchive -archivePath ' + XCARCHIVE_PATH_1 + ' -exportPath ' + TARGET_IPA_PATH + ' -exportOptionsPlist ' + EXPORT_OPTIONS_PLIST_PATH
sh '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -exportArchive -archivePath ' + XCARCHIVE_PATH_2 + ' -exportPath ' + TARGET_IPA_PATH + ' -exportOptionsPlist ' + EXPORT_OPTIONS_PLIST_PATH
sh '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -exportArchive -archivePath ' + XCARCHIVE_PATH_2 + ' -exportPath ' + TARGET_IPA_PATH + ' -exportOptionsPlist ' + EXPORT_OPTIONS_PLIST_PATH
}
}
}
}
在两个位置对配置文件ID进行硬编码感觉很不对劲1)exportOptions 2)jenkinsfile