我已经在a上设置了一个自托管代理Windows 10笔记本电脑(我有admin访问),我正在运行Azure DevOps Express 2020.
我按照以下网址的说明找到、下载并安装了代理下载并配置代理 https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/v2-windows?view=azure-devops#download-and-configure-the-agent。我用了vsts-agent-win-x64-2.170.1.zip
并将其设置为运行service,(我想任何手动运行它的人都需要仔细检查它是否在显示时运行)。我还运行了安装命令powershell 中的管理员!
要安装 Python 版本,我需要从以下位置下载适当的安装程序Python.org 上的 ftp 站点 https://www.python.org/ftp/python/,例如。对于 3.7.9 我用过python-3.7.9-amd64.exe
。
然后我从命令行运行它(以管理员身份运行CMD) 没有用户界面 https://docs.python.org/3/using/windows.html#installing-without-ui with:
python-3.7.9-amd64.exe /quiet InstallAllUsers=0 TargetDir=$AGENT_TOOLSDIRECTORY\Python\3.7.9\x64 Include_launcher=0
(其他安装选项可在蟒蛇文档 https://docs.python.org/3/using/windows.html#installing-without-ui)
完成后(并且它在后台运行,因此需要比初始命令更长的时间),您需要创建一个空的{platform}.complete
文件(如描述here https://learn.microsoft.com/en-gb/azure/devops/pipelines/tasks/tool/use-python-version?view=azure-devops#how-can-i-configure-a-self-hosted-agent-to-use-this-task),就我而言,这是x64.complete
.
这然后就起作用了!我确实为第一个版本重新启动了服务器,但我已经添加了其他 python 版本,而无需这样做。我的管道任务很简单:
steps:
- task: UsePythonVersion@0
displayName: 'Use Python $(python.version)'
inputs:
versionSpec: '$(python.version)'
(有一个变量python.version
将我们设置为版本列表3.7.9, 3.8.8
)
对我来说一个关键要素是文件结构,文档中说{tool files}
这意味着 python.exe 文件和其他常见目录,例如 Lib 和 Scripts。我最初将它们安装在一个子目录中,但不起作用。所以它应该看起来像这样:
$AGENT_TOOLSDIRECTORY/
Python/
3.7.9/
x64/
Doc/
Lib/
Scripts/
python.exe
...etc...
x64.complete
说实话,我很欣慰的是,这个方法没有遇到太多麻烦。我放弃了让 Artifacts 在本地运行的尝试。根据我有限的经验,所有这些在云版本上都更容易、更好。然而,还没有说服我的雇主迈出这一步......