Azure devops中的Docker任务将不接受"$(pwd)"作为变量 [英] Docker task in Azure devops won't accept "$(pwd)' as variable

查看:169
本文介绍了Azure devops中的Docker任务将不接受"$(pwd)"作为变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试通过Azure devops中的docker任务与docker内置任务一起运行docker命令.作为docker命令的音量变量,我将此值作为值

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.

我尝试在本地计算机中使用相同的-v值提供相同的docker run命令,这非常有效.所以我想这是Azure开发问题或我忘记给出的值

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

我的托管代理是ubuntu16并且构建任务如下

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

推荐答案

您正在尝试引用名为 pwd 的变量.没有没有这样的预定义变量在Azure Pipelines中.

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

您提到这在您的本地计算机上有效,但这不是因为定义了 pwd 变量.(实际上,您的环境中可能没有 一个 pwd 环境变量.)这是因为 $(pwd)

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.

此POSIX Shell语法在Azure Pipelines配置中不起作用.

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

相反,请使用 Azure中的一种管道变量.

例如,如果要映射源目录,可以将"volumes"字段设置为:

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

这篇关于Azure devops中的Docker任务将不接受"$(pwd)"作为变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆