我的目标是通过 Azure Pipeline 将我的 python 脚本从 GitHub 部署到我的虚拟机并运行。我的azure-pipelines.yml样子是这样的:
jobs:
- deployment: VMDeploy
displayName: Test_script
environment:
name: deploymentenvironment
resourceType: VirtualMachine
strategy:
rolling:
maxParallel: 2 #for percentages, mention as x%
preDeploy:
steps:
- download: current
- script: echo initialize, cleanup, backup, install certs
deploy:
steps:
- task: Bash@3
inputs:
targetType: 'inline'
script: python3 $(Agent.BuildDirectory)/test_file.py
routeTraffic:
steps:
- script: echo routing traffic
postRouteTraffic:
steps:
- script: echo health check post-route traffic
on:
failure:
steps:
- script: echo Restore from backup! This is on failure
success:
steps:
- script: echo Notify! This is on success
这将返回一个错误:
/usr/bin/python3: can't find '__main__' module in '/home/ubuntu/azagent/_work/1/test_file.py'
##[error]Bash exited with code '1'.
如果我将 放置到test_file.py并/home/ubuntu用以下内容替换部署脚本:script: python3 /home/ubuntu/test_file.py该脚本确实运行顺利。
如果我将 移动test_file.py到另一个目录,mv /home/ubuntu/azagent/_work/1/test_file.py /home/ubuntu我可以找到一个空文件夹,而不是一个.py文件,名为test_file.py
狐的传说
相关分类