I'm struggling to create YML file which will simply copy build artifacts (of my ASP.NET MVC app) to c:/samplefolder
on my virtual machine (Azure Agent). Can anyone help me with that please?
Everywhere I have searched there was some "pool" and "pool-name" needed, but I don't have any pool:
Or there were some examples with stages, tasks, but I cannot use them since it's one YML file.
Based on the limited information that we could see form the screenshot, your VM was added into a pipeline environment as a VM resource, which should be referenced by the environment
properties of deployment
jobs in a YAML pipeline rather than referenced by any pool
name, though it did generate a new deployment pool with the corresponding environment id.
Assuming your YAML pipeline was building your app on a Microsoft-hosted windows-latest
agent and had been publishing pipeline artifacts (drop
in my case), you may use a deployment
job in downstream stage (CD
) to scale out deployment onto all those VMs with web
and app
tags. All available artifacts from the current pipeline (downloaded to $(Pipeline.Workspace)/<artifact name>
) and from the associated pipeline resources are automatically downloaded in deployment jobs and made available for your deployment. Please take a look at the - deployment: DeployToMyVM
job in the sample YAML pipeline definition below.
stages:
- stage: CI
jobs:
- job: Build
pool:
vmImage: windows-latest
displayName: Build App
variables:
BuildPlatform: 'any cpu'
BuildConfiguration: 'release'
steps:
- powershell: |
Write-Host "Just to represent the steps to build your .NET framework app, even though the steps were irrelevant to the query in this post"
- publish: $(PathToTheArtifactsFileThatWasBuilt)
artifact: drop
- stage: CD
jobs:
- deployment: DeployToMyVM
environment:
name: MyVm
tags: app,web
resourceType: virtualMachine
strategy:
runOnce:
deploy:
steps:
- powershell: |
tree $(Pipeline.Workspace) /f /a
- task: CopyFiles@2
inputs:
SourceFolder: '$(Pipeline.Workspace)/drop'
Contents: '**'
TargetFolder: 'C:\samplefolder'
CleanTargetFolder: true
See more details in the following documents.
Create and target environments - Azure Pipelines | Microsoft Learn