来自 Jenkins 的参考 Xcode 版本号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24536041/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Reference Xcode version number from Jenkins
提问by James Parker
I'm trying to get a reference to my Xcode projects CFBundleVersionString or CFBundleVersion within my Jenkins Build.
我试图在我的 Jenkins Build 中获取对我的 Xcode 项目 CFBundleVersionString 或 CFBundleVersion 的引用。
My goal is to be able to set the build numbers in this sort of fashion ${CFBundleVersionString}.${build_number}. This way the Version is dictated by the project and the build number is added on when the project is built.
我的目标是能够以这种方式设置版本号 ${CFBundleVersionString}.${build_number}。这样,版本由项目决定,并在构建项目时添加构建编号。
Is this possible at all? I know that you can reference ${build_number}. Also I know that I could include a parameter in the build that is dictated, but I would prefer it all be managed through the Xcode project since our builds are triggered by github commits.
这可能吗?我知道您可以参考 ${build_number}。我也知道我可以在构建中包含一个指定的参数,但我更喜欢它全部通过 Xcode 项目管理,因为我们的构建是由 github 提交触发的。
采纳答案by antweiss
You can read CFBundleVersionString from your Info.plist file with:
您可以使用以下命令从 Info.plist 文件中读取 CFBundleVersionString:
export VERSION=`defaults read ${INFO_PLIST} CFBundleVersionString`
output this to a property file:
将其输出到属性文件:
echo VERSION=$VERSION > version.properties
and use this file to inject environment variables to your jenkins build. You can then use this variable with Build Name Setter pluginor simply us it in build mails.
并使用此文件将环境变量注入您的 jenkins 构建。然后,您可以将此变量与Build Name Setter 插件一起使用,或者只是在构建邮件中使用它。
Similarly you can update the version inside the plist with:
同样,您可以使用以下命令更新 plist 中的版本:
defaults write ${INFO_PLIST} CFBundleVersionString ${VERSION}.${BUILD_NUMBER}
回答by cohen72
If you are using the Xcode Plugin, you have CFBundleVersion
available as $VERSION and CFBundleShortVersionString
as $SHORT_VERSION.
如果您使用Xcode Plugin,您可以CFBundleVersion
使用 $VERSION 和CFBundleShortVersionString
$SHORT_VERSION。
I found $SHORT_VERSION by searching the XCode Plugin source code.
我通过搜索XCode 插件源代码找到了 $SHORT_VERSION 。
回答by Adrian_H
I have been looking everywhere for something that works from Jenkins.
我一直在到处寻找 Jenkins 有用的东西。
shortversionnumber=/usr/libexec/PlistBuddy -c "print CFBundleShortVersionString" ${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}
短版本号=/usr/libexec/PlistBuddy -c "print CFBundleShortVersionString" ${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}
But if your build has not happened yet, you will need to manually specify the location of the plist file.
但是如果你的构建还没有发生,你将需要手动指定 plist 文件的位置。
That is all!
就这些!