azure - 路径 "/home/vsts/work/1/s/javapipetest13/Orchestration/dev/deployment.yaml"不存在

标签 azure azure-devops azure-pipelines azure-aks azure-pipelines-yaml

运行管道时出现以下错误

==============================================================================
/usr/local/bin/kubectl apply -n default -f /home/vsts/work/1/s/javapipetest13/Orchestration/dev/deployment.yaml -o json
error: the path "/home/vsts/work/1/s/javapipetest13/Orchestration/dev/deployment.yaml" does not exist
##[error]error: the path "/home/vsts/work/1/s/javapipetest13/Orchestration/dev/deployment.yaml" does not exist
commandOutput
##[error]The process '/usr/local/bin/kubectl' failed with exit code 1
Finishing: Kubernetes

我的文件deployment.yml位于正确的路径中,但我不确定为什么管道未能显示路径未找到

enter image description here

这是我的 Docker 文件

FROM java:8-alpine
ENV APP_FILE='*-0.0.1-SNAPSHOT.jar'
#COPY ./lib/elastic-apm-agent-1.28.1.jar /lib
ENV APP_HOME=/usr/app
RUN mkdir /usr/app && touch /tmp/spring.log && chmod 777 /tmp/spring.log
EXPOSE 8080 8090 8091
COPY target/$APP_FILE $APP_HOME/
CMD java -jar $APP_HOME/$APP_FILE

这是启动部署文件的管道步骤,但在此步骤中出现错误

- task: Kubernetes@1
    inputs:
      connectionType: 'Azure Resource Manager'
      azureSubscriptionEndpoint: 'sc-icndp'
      azureResourceGroup: 'eus-icndp-rg'
      kubernetesCluster: 'icndp-aks'
      namespace: 'default'
      command: 'apply'
      arguments: '-f $(Build.SourcesDirectory)/$(Build.Repository.Name)/Orchestration/dev/deployment.yaml'

最佳答案

从您的 YAML 示例和存储库的屏幕截图中,您需要确认您是否正在检查管道中的单个存储库。

如果是,文件路径将不包含存储库名称。

您可以更改路径:$(Build.SourcesDirectory)/Orchestration/dev/deployment.yaml

请参阅此文档:Checkout path

Single repository: If you have a single checkout step in your job, or you have no checkout step which is equivalent to checkout: self, your source code is checked out into a directory called s located as a subfolder of (Agent.BuildDirectory). If (Agent.BuildDirectory) is C:\agent_work\1, your code is checked out to C:\agent_work\1\s.

Multiple repositories: If you have multiple checkout steps in your job, your source code is checked out into directories named after the repositories as a subfolder of s in (Agent.BuildDirectory). If (Agent.BuildDirectory) is C:\agent_work\1 and your repositories are named tools and code, your code is checked out to C:\agent_work\1\s\tools and C:\agent_work\1\s\code.

关于azure - 路径 "/home/vsts/work/1/s/javapipetest13/Orchestration/dev/deployment.yaml"不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73140116/

相关文章:

azure-devops - 对象作为管道变量

azure - 如何从快照创建 azure 图像?

azure - 从 Azure Functions 访问 Azure Key Vault 时访问被拒绝

build - 使用带有相对路径的 VS Online "Command Line"任务

version-control - 待定更改 : "edit , [more]" mean? 是什么意思

azure - 对象/变量内的搜索字符串 - Powershell

azure : Deploy Angular(Front-End) & Node (Back-End) app without VM

azure - Azure 转录 JSON 文件的 VTT 输出

azure-devops - Azure yaml 构建和发布管道

azure - 从 Azure DevOps yaml 设置应用服务应用程序设置