【发布时间】:2020-11-20 02:43:20
【问题描述】:
相关 repo 中的文件在运行 Azure Dev Ops 管道的构建阶段时可用,但在运行部署阶段时不可用。关于为什么会这样的任何想法?
这里是简化版的 yaml 文件:
# Deploy to Azure Kubernetes Service
# Build and push image to Azure Container Registry; Deploy to Azure Kubernetes Service
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
trigger:
- master
resources:
- repo: self
variables:
# Agent VM image name
vmImageName: 'ubuntu-latest'
# Name of the new namespace being created to deploy the PR changes.
k8sNamespaceForPR: 'review-app-$(System.PullRequest.PullRequestId)'
stages:
- stage: Build
displayName: Build stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: Bash@3
inputs:
targetType: 'inline'
script: |
pwd
ls -la
- stage: Deploy
displayName: Deploy stage
dependsOn: Build
jobs:
- deployment: Deploy
condition: and(succeeded(), not(startsWith(variables['Build.SourceBranch'], 'refs/pull/')))
displayName: Deploy
pool:
vmImage: $(vmImageName)
environment: 'test.development'
strategy:
runOnce:
deploy:
steps:
- task: Bash@3
inputs:
targetType: 'inline'
script: |
pwd
ls -la
补充说明: 如果首先运行部署阶段(删除构建阶段),则工作目录也是空的。
【问题讨论】:
-
可能是 build 只生成 artifcat。你能添加更多细节吗
-
我已经添加了yaml文件。
-
问题似乎与构建阶段无关。
-
您查看过微软提供的 YAML 文档吗?它解释了什么是部署作业以及它们与非部署作业的区别。
-
在构建阶段,有一个包含默认签出步骤的构建作业。在 Deploy 阶段,它是一个部署作业,因此没有默认的签出步骤。这就是为什么项目文件在部署作业中不可用的原因。尼克格雷厄姆提供了一个很好的答案,你可以检查一下,如果它对你有帮助,你可以Accept it as an Answer。这可能对阅读此主题的其他社区成员有益,我们可以关闭此主题,谢谢
标签: azure azure-devops azure-pipelines