Jac*_*ers 3 yaml azure azure-devops azure-pipelines
I have a CI pipeline (YAML) that builds a repo that will deploy into an existing Azure Function. The CI pipeline is doing it is job. However, after it is done, and I go to Function App -> App files -> I can see the azure-pipeline.yml is included in there (or i think it was included in the build process). I have tried using paths and exclude but they dont work. My question is, how do I exclude only that azure-pipeline.yml so that after the pipeline is done building, the azure-pipeline.yml is not in App files in Function App. Below is my YAML
trigger:
branches:
include:
- master
paths:
exclude:
- README.md
- azure-pipelines.yml
variables:
# Azure Resource Manager connection created during pipeline creation
azureSubscription: 'DevOps-Test'
# Function app name
functionAppName: 'test'
# Agent VM image name
vmImageName: 'vs2017-win2016'
# Working Directory
workingDirectory: '$(System.DefaultWorkingDirectory)/'
stages:
- stage: Build
displayName: Build stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- powershell: |
if (Test-Path "extensions.csproj") {
dotnet build extensions.csproj --output ./$(workingDirectory)/bin
}
displayName: 'Build extensions'
- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: $(workingDirectory)
includeRootFolder: false
archiveType: zip
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
replaceExistingArchive: true
- publish: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
artifact: drop
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'drop'
downloadPath: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
- task: AzureFunctionApp@1
displayName: 'Azure functions app deploy'
inputs:
azureSubscription: '$(azureSubscription)'
appType: functionApp
appName: $(functionAppName)
package: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
Run Code Online (Sandbox Code Playgroud)
以下语法表示文件README.md或azure-pipelines.yml不会触发构建。这并不意味着文件README.md或被azure-pipelines.yml排除在工作目录中。
trigger:
branches:
include:
- master
paths:
exclude:
- README.md
- azure-pipelines.yml
Run Code Online (Sandbox Code Playgroud)
我注意到您尝试了归档文件夹$(workingDirectory),并workingDirectory在变量中定义,这实际上是$(System.DefaultWorkingDirectory)/. System.DefaultWorkingDirectory是代理上下载源代码文件的本地路径。
显然,fileREADME.md和azure-pipelines.yml都在源代码中,所以它们也被存档了。您可以添加CopyFiles task之前ArchiveFiles task使用匹配模式将所需文件从源文件夹复制到目标文件夹,然后存档目标文件夹。例如:
- task: CopyFiles@2
displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory) '
inputs:
SourceFolder: '$(workingDirectory)'
Contents: |
**/*
!*.md
!*.yml
TargetFolder: '$(Build.ArtifactStagingDirectory) '
- task: ArchiveFiles@2
displayName: 'Archive files '
inputs:
rootFolderOrFile: '$(Build.ArtifactStagingDirectory) '
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10106 次 |
| 最近记录: |