【发布时间】:2021-11-15 03:09:08
【问题描述】:
我已经为虚拟机创建了一个 Azure 代理环境,我将构建下载到该文件夹中。我有以下 yaml 文件
# Python package
# Create and test a Python package on multiple Python versions. OK
# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/python
trigger:
paths:
include:
- Flytteordre
pool:
vmImage: 'ubuntu-latest'
name: Azure Pipelines
variables:
python.version: '3.6'
stages:
- stage: Build
displayName: Build stage
jobs:
- job: build
displayName: build
steps:
- task: UsePythonVersion@0
displayName: 'Use Python $(python.version) copy'
inputs:
versionSpec: '$(python.version)'
# We actually don't need to install these dependencies here. It needs to happen in the deploy yaml file.
- task: CmdLine@2
inputs:
script: |
python -m pip install --upgrade pip
python -m pip install selenium
python -m pip install pdfplumber
python -m pip install pandas
displayName: 'Install dependencies'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: dist'
inputs:
PathtoPublish: Flytteordre
ArtifactName: dist
- stage: Deployment
displayName: Deployment stage
jobs:
- deployment: deploymentJob
displayName: Deploy
environment:
name: Production
resourceType: VirtualMachine
strategy:
runOnce:
deploy:
steps:
- download: none
- downloadBuild: none
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'dist'
downloadPath: 'C:/azagent/A1/_work/myfolder/'
我的问题是,每次我运行管道时,它都会在 _work 环境中创建一个名为 1、2 等的文件夹。
我想避免这种情况,以便完全控制创建哪些文件夹。正如你所看到的,我已经指出我的工件应该下载到文件夹路径 C:/azagent/A1/_work/myfolder/,但是这将创建两个文件夹。一个是我指定的文件夹,另一个是带有数字标题的文件夹。我现在这是默认设置,但我想知道是否有办法关闭此默认设置,或者至少能够更改预定义的路径变量 PIPELINE.WORKSPACE 或 Agent.BuildDirectory?
【问题讨论】:
-
我的问题是每次我运行管道时,它都会在 _work 环境中创建一个名为 1、2 等的文件夹。。您能否解释一下为什么您认为这是一个问题?这种行为是正确的,并且是设计使然。如果您可以解释您遇到的问题并尝试解决,则可以提供更好的指导。
-
我更喜欢能够自己命名目录的选项,以防我需要查找特定项目并在本地代理上打开它。如果我有 30 个名为 1,2,...30 的项目,如果我们必须进入并打开每个文件夹,我或其他同事将需要一些时间来找到确切的项目。这就是为什么我有 DownloadBuildArtifacts 任务的原因,我在其中指明了下载路径。这在一定程度上解决了我的问题,因为我有一个带有我选择的名称的目录。
-
但是,使用此解决方案,我仍然会得到一个名为“1”的不必要目录,我不会使用它。如果我进去手动删除它,它只会在下一个构建中创建。因此,我想知道是否有解决方法可以关闭此默认设置?
-
我尝试在末尾添加一个删除文件夹任务,该任务会删除新创建的名为“1”、“2”等的文件夹。但是它无法删除它,因为它说有一个文件夹使用中,即 1/s 文件夹,即使它是空的。
-
如果我需要找到一个特定的项目并在本地代理上打开它,我更喜欢能够自己命名目录的选项。 为什么?没有理由在代理的工作文件夹中四处挖掘。我还是不明白你要解决什么问题。正如我所说,您看到的行为是正确和故意。更改它可能会破坏某些东西。
标签: azure azure-devops yaml azure-pipelines azure-pipelines-yaml