Docker task in Azure devops won't accept "$(pwd)' as variable

∥☆過路亽.° 提交于 2021-01-27 12:08:02

问题


I tried to run a docker command through the docker task in Azure devops with the build in docker task. As variable for the volume of the docker command I gave this as value

But it keeps failing with the error

/usr/bin/docker: Error response from daemon: create $(pwd)/out: "$(pwd)/out" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path.

I tried to give the same docker run command with the same -v value inside my local machine and this works perfectly. So I guess this is an Azure devops problem or a value that I forget to give along

My host agent is an ubuntu16 And the build task is as followed


回答1:


You're trying to reference a variable named pwd. There is no such predefined variable in Azure Pipelines.

You mention that this works in your local machine, but that's not because there's a pwd variable defined. (In fact, there's probably not a pwd environment variable in your environment.) That's because $(pwd) is POSIX command substitution. It's actually executing the pwd command.

This POSIX shell syntax will not work in Azure Pipelines configuration.

Instead, use one of the Azure Pipelines variables.

For example, if you want to map the sources directory, you can set the volumes field to:

$(Build.SourcesDirectory):/src

Or map source and binaries:

 $(Build.SourcesDirectory):/src
 $(Build.BinariesDirectory):/build


来源:https://stackoverflow.com/questions/54143789/docker-task-in-azure-devops-wont-accept-pwd-as-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!