Description
openedon May 23, 2024
Describe your feature request here
I have set up a self-hosted agent in a Docker container.
And since I have pipelines using MegaLinter, I am running into this problem.
I miss more information in that section as no concrete examples come out. I mean, to solve this problem in the best possible way and that the pipeline works in any agent, I don't want to put an absolute hardcoded path to the host obviously...
I have the problem that among the available environment variables there is not one that solves the root path of the agent in the host to be able to build the relative path as for example: $AZP_HOST_ROOT/_work/1/s.
So I had to create that AZP_HOST_ROOT
variable on my own pointing to the corresponding path and then do all this scripting in powershell:
$originalWorkDirectoryPath = '$(Agent.WorkFolder)'
$originalArtifactStagingDirectoryPath = '$(Build.ArtifactStagingDirectory)'
$originalSourcesDirectoryPath = '$(Build.SourcesDirectory)'
$relativeArtifactStagingDirectoryPath = $originalArtifactStagingDirectoryPath.Replace($originalWorkDirectoryPath, '')
$relativeSourcesDirectoryPath = $originalSourcesDirectoryPath.Replace($originalWorkDirectoryPath, '')
$hostDirectoryPath = $Env:AZP_HOST_ROOT
$workDirectoryPath = [System.IO.Path]::Combine($hostDirectoryPath , $Env:AZP_WORK)
$artifactsStagingDirectoryPath = [System.IO.Path]::Combine($workDirectoryPath, $relativeArtifactStagingDirectoryPath)
$sourcesDirectoryPath = [System.IO.Path]::Combine($workDirectoryPath, $relativeSourcesDirectoryPath)
Would it be possible for you to expose such an environment variable or is it something that you will not want to support in any way? Because even if so it would be nice to at least have an example of how to solve this case? As I say, in this section I see that more useful information is missing...
It may also make more sense to create an AZP_HOST_WORK
variable because when you mount volumes it makes more sense to do it from the work folder which makes more sense to persist.