我有一个Jenkins管道作业,它构建iOS代码,创建.app文件并对其运行测试。这些作业由iOS存储库中的PRs触发。一次可以有大约4-5个并行构建运行。
成型机的配置:
例如
jenkins-workspace-folder-on-mac-machine/
-> build/ (folder created by a job that builds .app file for a PR)
-> build@2/ (another folder created by a parallel job that builds .app for a PR)
-> build@3/ (another folder created by a parallel job that builds .app for a PR)这是我的Jenkinsfile脚本供参考:
stages {
stage('Clean Workspace') {
steps {
cleanWs deleteDirs: true, patterns: [[pattern: '**/Podfile.lock', type: 'EXCLUDE'], [pattern: '**/Pods/**', type: 'EXCLUDE'], [pattern: '**/Podfile', type: 'EXCLUDE'], [pattern: '**/Carthage/**', type: 'EXCLUDE'], [pattern: '**/Cartfile', type: 'EXCLUDE'], [pattern: '**/Cartfile.lock', type: 'EXCLUDE'], [pattern: '**/Cartfile.private', type: 'EXCLUDE'], [pattern: '**/Cartfile.resolved', type: 'EXCLUDE'], [pattern: '**/Gemfile', type: 'EXCLUDE'], [pattern: '**/Gemfile.lock', type: 'EXCLUDE']]
}
}
/* Download and checkout iOS repository in the workplace.
Also set all the keys for iOS into .env file */
stage('Checkout iOS Source repository') {
steps{
checkout([$class: 'GitSCM', branches: [[name: "${PR_BRANCH}"]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'abc', url: 'https://github.com/abc']]])
}
}
/* Install all dependencies. These will be skipped if repo folder is not cleaned in the beginning.
Full install will be done if an executor has to clone the repository from scratch*/
stage('Install dependencies') {
steps {
sh '''
bundle install
make install
'''
}
}
stage('Build .app file and trigger tests') {
steps {//This will perform xcode build and build .app file }我面临的问题:
Podfile, Pod folder, podfile.lock, Carthage folder, Cartfile, Cartfile.private, Cartfile.resolved, Gemfile, Gemfile.lock,这将加快构建。但这不管用。*** Checking out Nimble at "v8.0.4"
A shell task (/usr/bin/env git checkout --quiet --force v8.0.4 (launched in /Users/user/Library/Caches/org.carthage.CarthageKit/dependencies/Nimble)) failed with exit code 1:
error: pathspec 'v8.0.4' did not match any file(s) known to git
make: *** [carthage-install] Error 1### Error
Errno::ENOENT - No such file or directory @ rb_file_s_stat - /Users/user/Library/Caches/CocoaPods/Pods/Release/Flurry-iOS-SDK/8.4.0-0c448bundle exec pod install
Analyzing dependencies
Pre-downloading: `CLImageEditor` from `git@github.com/CLImageEditor.git`, commit `96e78cdf95761170d5bf11653a8257a3ccfeb19a`
[!] Failed to download 'CLImageEditor': Directory not empty @ dir_s_rmdir - /Users/user/Library/Caches/CocoaPods/Pods
make: *** [pod-install] Error 1如果有人能帮我理解我在这里做错了什么,那就太好了。
发布于 2020-05-21 03:29:26
我根据不同版本的Gemfile.lock、Podfile.lock和Cartfile.resolved编写了一个脚本来管理cocoapods、gems和carthage的依赖项缓存,从而解决了这个问题。
在Jenkinsfile中管理缓存的示例脚本
sh '''
set +x
mkdir -p ${HOME}/ioscache/pod
# CocoaPods
POD_SHASUM=$(shasum Podfile.lock | awk '{print $1}')
POD_KEY="pod-${POD_SHASUM}"
POD_CACHE_PATH="${HOME}/ioscache/pod/${POD_KEY}.tar.gz"
echo "Checking cache for CocoaPods with they key: $POD_KEY"
if [ ! -e "${POD_CACHE_PATH}" ]; then
echo "CocoaPods cache not found with the key: $POD_KEY"
POD_CACHE_FOUND=false
else
echo "CocoaPods cache found with the key: $POD_KEY"
echo "restoring cache.."
tar xf ${POD_CACHE_PATH}
POD_CACHE_FOUND=true
fi
make pod-install
if [ "$POD_CACHE_FOUND" = "false" ]; then
echo "Saving cache for CocoaPods with key: $POD_KEY"
tar cfz ${POD_CACHE_PATH} Pods/
echo "Saved."
fi
'''对Gemfile.lock和Cartfile.resolved重复相同的操作。
发布于 2019-10-04 06:07:01
我可以看到,您正在构建脚本中执行pod install,Cocoapods随后正在下载依赖项。我认为,Cocoapods同时下载依赖项的多个实例可能是您发布的3个错误中的2个原因。至少,它肯定会减缓您的构建。
是否可以将您的Pods目录与源代码一起签入git?这样做有好处也有缺点,但这是一种常见的做法,甚至是Cocoapods开发人员推荐的。然后,您可以从构建脚本中删除pod install步骤,这将大大加快速度。
https://stackoverflow.com/questions/58229687
复制相似问题