【问题标题】:the path "/home/vsts/work/1/s/javapipetest13/Orchestration/dev/deployment.yaml" does not exist路径“/home/vsts/work/1/s/javapipetest13/Orchestration/dev/deployment.yaml”不存在
【发布时间】:2022-07-28 16:04:08
【问题描述】:

运行管道时出现以下错误

==============================================================================
/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,但我不确定为什么管道没有说找不到路径

这是我的 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'

【问题讨论】:

  • 您可以通过使用“pwd”命令检查您当前的工作目录并使用“ls -a”找到您要查找的文件的确切路径来解决此问题。将这些添加为任务,您将能够解决它。希望对您有所帮助。

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


【解决方案1】:

从您的 YAML 示例和 Repo 的屏幕截图中,您需要确认您是否在管道中检出单个 repo。

如果是,则文件路径将不包含 repo 名称。

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

请参阅此文档:Checkout path

单个存储库:如果您的作业中有一个签出步骤,或者您没有与 checkout: self 等效的签出步骤,则您的源代码将签出到名为 s 的目录中,该目录位于 (Agent.构建目录)。如果 (Agent.BuildDirectory) 为 C:\agent_work\1,则您的代码将检出到 C:\agent_work\1\s。

多个存储库:如果您的作业中有多个签出步骤,您的源代码将签出到以存储库命名的目录中,作为 (Agent.BuildDirectory) 中 s 的子文件夹。如果 (Agent.BuildDirectory) 为 C:\agent_work\1 并且您的存储库被命名为 tools 和 code,则您的代码将检出到 C:\agent_work\1\s\tools 和 C:\agent_work\1\s\code。

【讨论】:

    猜你喜欢
    • 2020-11-06
    • 1970-01-01
    • 2021-10-03
    • 1970-01-01
    • 1970-01-01
    • 2022-06-17
    • 1970-01-01
    • 2019-09-11
    • 1970-01-01
    相关资源
    最近更新 更多