I have a groovy file that I used for my iOS job. version=$(
gives syntax error when trying to build. If I escape the sign with \\$
that line doesn't work. How can I solve it?
stage('XCode')
{
sh """
if [ "${appName}" == "" ]; then
echo "INVALID appName!"
exit 1
fi
if [ "${schemeName}" == "" ]; then
echo "INVALID Scheme Name!"
exit 1
fi
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${buildNumber}" "${WORKSPACE}/iOS_App/App/Supporting Files/AppProd-Info.plist"
/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${WORKSPACE}/iOS_App/App/Supporting Files/AppProd-Info.plist"
version=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${WORKSPACE}/iOS_App/App/Supporting Files/AppProd-Info.plist")
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${buildNumber}" "${WORKSPACE}/iOS_App/App/AppNotifServiceExtensionProdInfo.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $version" "${WORKSPACE}/iOS_App/App/AppNotifServiceExtensionProdInfo.plist"
/usr/bin/xcodebuild -quiet -workspace iOS_App/${workspaceName} -scheme ${schemeName} -sdk iphoneos -configuration Release archive -archivePath ${WORKSPACE}/build/${appName}.xcarchive
/usr/bin/xcodebuild -exportArchive -archivePath ${WORKSPACE}/build/${appName}.xcarchive -exportOptionsPlist 'iOS_App/App/Supporting Files/${environment}_ExportOptions.plist' -exportPath ${WORKSPACE}/build
"""
}
I have escape the dollar sign I get below error:
groovy.lang.MissingPropertyException: No such property: version for class: groovy.lang.Binding
I solve it by also escaping dolar sign on where I used it. Adding \\
to :CFBundleShortVersionString \\$version
solve the problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.