Per these instructions我正在为Linux Web App创建集成CI / CD的devops项目。
这是我最初的管道管道/构建工作
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
inputs:
versionSpec: '12.x'
displayName: 'Install Node.js'
- script: |
npm install -g @angular/cli
npm install
npm run build:ssr
displayName: 'npm install and build'
- task: CopyFiles@2
inputs:
Contents: |
dist/**
node_modules/**
package.json
TargetFolder: '$(Build.ArtifactStagingDirectory)'
CleanTargetFolder: true
OverWrite: true
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
由于CopyFiles@2
任务有65000个文件复制到要在以下PublishBuildArtifacts@1
任务中发布的目录中。
因此,我想我可以在复制任务之后添加Artifact
任务,这将产生一个.zip
文件,并使部署效率更高,速度更快。
但是,情况并非如此,它所做的全部工作只是将文件夹压缩,解压缩文件夹并继续执行相同的单个文件处理,如下所示。在我写这篇文章的时候,已经花了大约14分钟,这已经走了多远。
Async Command Start: Upload Artifact
Uploading 65244 files
Total file: 65244 ---- Processed file: 69 (0%)
Total file: 65244 ---- Processed file: 200 (0%)
Total file: 65244 ---- Processed file: 333 (0%)
Total file: 65244 ---- Processed file: 460 (0%)
Total file: 65244 ---- Processed file: 603 (0%)
Total file: 65244 ---- Processed file: 746 (1%)
Total file: 65244 ---- Processed file: 884 (1%)
Total file: 65244 ---- Processed file: 1026 (1%)
Total file: 65244 ---- Processed file: 1142 (1%)
Total file: 65244 ---- Processed file: 1268 (1%)
Total file: 65244 ---- Processed file: 1365 (2%)
Total file: 65244 ---- Processed file: 1509 (2%)
Total file: 65244 ---- Processed file: 1672 (2%)
Total file: 65244 ---- Processed file: 1839 (2%)
Total file: 65244 ---- Processed file: 1993 (3%)
Total file: 65244 ---- Processed file: 2188 (3%)
Total file: 65244 ---- Processed file: 2362 (3%)
Total file: 65244 ---- Processed file: 2540 (3%)
Total file: 65244 ---- Processed file: 2701 (4%)
Total file: 65244 ---- Processed file: 2854 (4%)
Total file: 65244 ---- Processed file: 3051 (4%)
Total file: 65244 ---- Processed file: 3256 (4%)
Total file: 65244 ---- Processed file: 3459 (5%)
Total file: 65244 ---- Processed file: 3656 (5%)
Total file: 65244 ---- Processed file: 3836 (5%)
Total file: 65244 ---- Processed file: 4025 (6%)
Total file: 65244 ---- Processed file: 4196 (6%)
Total file: 65244 ---- Processed file: 4385 (6%)
Total file: 65244 ---- Processed file: 4545 (6%)
Total file: 65244 ---- Processed file: 4694 (7%)
Total file: 65244 ---- Processed file: 4864 (7%)
Total file: 65244 ---- Processed file: 5044 (7%)
Total file: 65244 ---- Processed file: 5253 (8%)
Total file: 65244 ---- Processed file: 5422 (8%)
Total file: 65244 ---- Processed file: 5620 (8%)
有没有一种方法可以满足我的需求?我是否应该复制然后压缩而不是仅压缩?这是因为它是Linux途径与Windows途径。
到目前为止,由于部署将花费一个小时,因此将无法利用。
这里是Deploy Azure App Service
任务的任务
steps:
- task: AzureRmWebAppDeployment@4
displayName: 'Deploy Azure App Service'
inputs:
azureSubscription: '$(Parameters.ConnectedServiceName)'
appType: '$(Parameters.WebAppKind)'
WebAppName: '$(Parameters.WebAppName)'
packageForLinux: '$(System.DefaultWorkingDirectory)/**/**/*.zip'
RuntimeStack: 'NODE|12-lts'
StartupCommand: '$(Parameters.StartupCommand)'
是,您可以将特定的文件夹存档到zip,7z或tar存档中。然后,您可以仅将归档作为管道中的工件发布。这是将dist
,node_modules
和package.json
内容归档到zip,然后将其作为工件发布的示例。
这里重要的一点是存档任务上的replaceExistingArchive: false
,这会将每个文件夹/文件添加到存档中。一个例外是,如果您存档到压缩的TAR文件,则这些文件将始终被完全替换。 (Source)
此外,Artifact任务只是发布文件,以便它们在管道外部可用,它不会将它们压缩为存档。
steps:
- task: ArchiveFiles@2
displayName: 'Archive Dist Folder'
inputs:
rootFolderOrFile: 'dist'
includeRootFolder: false
archiveFile: '$(Build.ArtifactStagingDirectory)/archive.zip'
replaceExistingArchive: false
- task: ArchiveFiles@2
displayName: 'Archive node_modules Folder'
inputs:
rootFolderOrFile: 'node_modules'
includeRootFolder: false
archiveFile: '$(Build.ArtifactStagingDirectory)/archive.zip'
replaceExistingArchive: false
- task: ArchiveFiles@2
displayName: 'Archive package.json File'
inputs:
rootFolderOrFile: 'package.json'
includeRootFolder: false
archiveFile: '$(Build.ArtifactStagingDirectory)/archive.zip'
replaceExistingArchive: false
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/archive.zip'
ArtifactName: 'drop'
publishLocation: 'Container'