My setup consists of a windows server on which some containers have been deployed. Every container is a build vsts agent that can perform builds and deployments. I am trying to figure if I could share the directory C:\agent\work
across multiple containers in order to have a centralized artifacts directory.
In order to share C:\agent:\work
I can use a specific path and create each container with volume mapping to this directory for example
Container1: docker run agent1 -v C:\artifacts:C:\agent\work
Container2: docker run agent2 -v C:\artifacts:C:\agent\work
With this solution however I tested and was able to determine that each container will keep in each own SourceRootMapping folder the build number and every time two containers have the same working directory this will be overridden. As I need to keep for some days artifacts I cannot continue with this solution.
Is there a way to have different vsts agents share the same C:\agent\work
directory?
I need to share this directory so that every agent can locate files that have been created from another container for example if Agent1 creates the files under C:\agent\work\5
I want those files to be accessible from Agent2 in order to perform the release.
The solution which I chose for this problem was to store the artifacts on a separate directory for example C:\artifacts
on each container. The build process will output the artifacts on a unique directory using builID
and $(artifactsPath) -> C:\artifacts
Then the C:\artifacts
directory of the containers will be shared across all containers with a mapping on the host machine:
docker run --name image1 -v S:\artifacts:C:\artifacts
Publish artifacts:
task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: '$(build.BuildId)'
publishLocation: 'FilePath'
TargetPath: '$(artifactsPath)\$(Build.DefinitionName)\drop'