我有这个管道,它工作得很好,但是每次构建都非常耗时,在桌面 xcode 中,构建时间不到 5 分钟,在 mac 云服务器中,它需要 20
尤其是它下载的部分,在
“安装”中配置和编译本机 gem gems and cocoapods script”任务如下
,然后是Fastlane任务:“run fastlane”
,其中编译部分非常慢......
我正在寻找提示和技巧或更好地组织我的管道以更快地构建
pool:
vmImage: 'macOS 10.14'
variables:
scheme: ''
sdk: 'iphoneos'
configuration: 'Release'
jobs:
- job: self_hosted_connect
timeoutInMinutes: 10
pool: Default
steps:
- task: CopyFiles@2
inputs:
SourceFolder: '$(Agent.HomeDirectory)/../${{parameters.Folderpath}}'
Contents: '**'
TargetFolder: '$(build.artifactstagingdirectory)'
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '$(build.artifactstagingdirectory)'
artifactName: 'ios_artifacts'
- job: mac_agent
dependsOn: self_hosted_connect
timeoutInMinutes: 30
pool:
vmImage: 'macOS 10.14'
steps:
- script: echo 'Setting up macOS 10.14'
- task: UseRubyVersion@0
inputs:
versionSpec: '>= 2.4'
addToPath: true
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'ios_artifacts'
downloadPath: '$(System.ArtifactsDirectory)'
- script: |
gem install --no-document bundler
bundle update --bundler
bundle install --retry=3 --jobs=4
gem install --no-document fastlane
pod deintegrate
gem install cocoapods
pod install
pod --version
workingDirectory: '$(System.ArtifactsDirectory)/ios_artifacts'
displayName: 'installing gems and cocoapods'
- script: |
echo 'Start invoking Fastfile'
fastlane release --verbose
echo 'Done invoking Fastfile'
failOnStderr: false
workingDirectory: '$(System.ArtifactsDirectory)/ios_artifacts'
displayName: 'run fastlane'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'Artifacts'
publishLocation: 'Container'
- job: copy_back_files_to_self_hosted_connect
dependsOn: mac_agent
timeoutInMinutes: 30
pool: Default
steps:
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'Artifacts'
itemPattern: |
**/*.ipa
**/*manifest.plist*
downloadPath: '$(System.ArtifactsDirectory)'
- task: CopyFiles@2
inputs:
SourceFolder: '$(System.ArtifactsDirectory)'
Contents: |
**/*.ipa
**/*manifest.plist*
TargetFolder: '$(Agent.HomeDirectory)/../${{parameters.FolderCompile}}'
使用缓存更新
我添加了缓存部分,但是当我运行它时它给了我一个错误
Resolving key:
2020-10-01T11:39:48.3151700Z - gems [string]
2020-10-01T11:39:48.3241700Z - "Darwin" [string]
2020-10-01T11:39:48.3720810Z - my.gemspec [file] (not found)
2020-10-01T11:39:48.3882910Z ##[error]One or more errors occurred. (File not found: my.gemspec)
2020-10-01T11:39:48.4094600Z ##[section]Finishing: Cache gems
池:vmImage:'macOS 10.14'
variables:
scheme: ''
sdk: 'iphoneos'
configuration: 'Release'
BUNDLE_PATH: $(Pipeline.Workspace)/.bundle
jobs:
- job: self_hosted_connect
timeoutInMinutes: 10
pool: Default
steps:
- task: CopyFiles@2
inputs:
SourceFolder: '$(Agent.HomeDirectory)/../${{parameters.Folderpath}}'
Contents: '**'
TargetFolder: '$(build.artifactstagingdirectory)'
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '$(build.artifactstagingdirectory)'
artifactName: 'ios_artifacts'
- job: mac_agent
dependsOn: self_hosted_connect
timeoutInMinutes: 30
pool:
vmImage: 'macOS 10.14'
steps:
- script: echo 'Setting up macOS 10.14'
- task: UseRubyVersion@0
inputs:
versionSpec: '>= 2.4'
addToPath: true
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'ios_artifacts'
downloadPath: '$(System.ArtifactsDirectory)'
- task: Cache@2
inputs:
key: 'gems | "$(Agent.OS)" | my.gemspec'
restoreKeys: |
gems | "$(Agent.OS)"
gems
path: $(BUNDLE_PATH)
displayName: Cache gems
- script: |
gem install --no-document bundler
bundle update --bundler
bundle install --retry=3 --jobs=4
gem install --no-document fastlane
workingDirectory: '$(System.ArtifactsDirectory)/ios_artifacts'
displayName: 'installing gems and cocoapods'
- script: |
pod deintegrate
gem install cocoapods
pod install
pod --version
workingDirectory: '$(System.ArtifactsDirectory)/ios_artifacts'
displayName: 'pod and cocoapods install '
- script: |
echo 'Start invoking Fastfile'
fastlane release --verbose
echo 'Done invoking Fastfile'
failOnStderr: false
workingDirectory: '$(System.ArtifactsDirectory)/ios_artifacts'
displayName: 'run fastlane'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'Artifacts'
publishLocation: 'Container'
- job: copy_back_files_to_self_hosted_connect
dependsOn: mac_agent
timeoutInMinutes: 30
pool: Default
steps:
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'Artifacts'
itemPattern: |
**/*.ipa
**/*manifest.plist*
downloadPath: '$(System.ArtifactsDirectory)'
- task: CopyFiles@2
inputs:
SourceFolder: '$(System.ArtifactsDirectory)'
Contents: |
**/*.ipa
**/*manifest.plist*
TargetFolder: '$(Agent.HomeDirectory)/../${{parameters.FolderCompile}}'