在 Azure Devops yaml 部署管道中使用脚本文件

问题描述 投票:0回答:1

在我的构建管道中,我使用了多个 bash 脚本,参考了

Bash@3
任务,如下所示。

现在我尝试在

deployment
中使用脚本,但我似乎找不到脚本文件。我已经使用
tree
命令从多个路径(甚至从根目录)搜索了代理磁盘,但找不到
bash_scripts
目录。

请参阅下面片段中的

#
注释以获取解释。

trigger: none

pool:
  vmImage: ubuntu-latest

variables:
- template: ./variables/dev-variables.yml # Works
- template: ./variables/common-variables.yml # Works

stages:
- stage: DeployToDev
  displayName: Deploy to Dev Environment
  jobs:
  - template: ./jobs/get-docker-tags.yml # Works
  - deployment: DeployToACR
    displayName: Deploy to ACR
    dependsOn: GetDockerImageTagsJob
    environment:
      name: $(adoEnvironment)
    strategy:
      runOnce:
        deploy:
          steps:
          - script: ls $(System.DefaultWorkingDirectory)
          - script: tree /home/vsts/work/
          - script: tree $(System.DefaultWorkingDirectory)
          - script: tree $(Agent.WorkFolder)
          - script: tree $(Pipeline.Workspace)
          - script: tree /
          - task: Bash@3
            displayName: 'Get Image With Tag'
            name: GetImageWithTag
            inputs:
              targetType: 'filePath'
              filePath: 'bash_scripts/getImageToDeploy.sh' # Doesn't work
... Deployment
azure-devops yaml azure-pipelines
1个回答
0
投票

deployment
作业中,默认情况下不会检出源代码。

将以下任务添加到您的步骤中:

steps:
  - checkout: self
  # other tasks here
© www.soinside.com 2019 - 2024. All rights reserved.