Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[enhancement]: Environment variable pointing to the host root path for docker agents #4810

Open
bdovaz opened this issue May 23, 2024 · 1 comment

Comments

@bdovaz
Copy link

bdovaz commented 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.

@DmitriiBobreshev
Copy link
Contributor

Hi @bdovaz, thank you for the good idea! For now, we have more prioritized issues but we'll try to implement it in the feature!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants