I'm using two different build servers, one for builds with static code analysis, one without, to build some large Windows solutions.
Building on the two servers works perfectly well, but after that's done, I need the artifacts on one server. There's quite a bit of built-in functionality to deal with artifacts, but I would very much prefer a direct file copy instead.
It works if I hard-code the directories like \\server1\DevOpsAgent\_work\1\b\
, but I will have a problem if the directory is not "1", or if the server name changes (I'm selecting servers via agent demands only).
Is there a way, at runtime, to find which directories the "other" server is using?
Haven't found an answer in the Microsoft documentation, or online.
TL;DR use pipeline artifacts (or, as an alternative, Universal Packages) instead of a direct file copy.
... I need the artifacts on one server. There's quite a bit of built-in functionality to deal with artifacts, but I would very much prefer a direct file copy instead.
I honestly don't see how using a direct file copy would simplify things, specially considering the issues you are already facing - using demands on agents, paths that might (and probably will) change, among others.
Also, you're trying to reinvent the wheel by using a workaround to solve a problem that was already solved a long, long time ago by the many CI/CD platforms out there: publishing and consuming artifacts between pipelines.
Most of the cases using pipeline artifacts is quite simple - the publish pipeline generates artifacts into a folder, copy these files into a staging directory (optional) and then publish these artifacts:
# Generate artifacts into the $(Build.ArtifactStagingDirectory) folder
- task: VSBuild@1
inputs:
solution: '**/*.sln'
msbuildArgs: 'p:DesktopBuildPackageLocation="$(Build.ArtifactStagingDirectory)\WebApp.zip" ...
platform: 'Any CPU'
configuration: 'Release'
# Publish files from $(Build.ArtifactStagingDirectory) folder as artifacts
- task: PublishPipelineArtifact@1
inputs:
targetPath: $(Build.ArtifactStagingDirectory)
artifactName: WebApp
The consuming pipeline/stage/job downloads the artifacts and then uses them to deploy applications, run a script, etc
- task: DownloadPipelineArtifact@2
inputs:
artifact: WebApp
targetPath: '$(System.DefaultWorkingDirectory)'
- task: AzureRmWebAppDeployment@4
inputs:
# other properties here
packageForLinux: '$(System.DefaultWorkingDirectory)/**/*.zip'