我的目標是通過 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用以下內(nèi)容替換部署腳本: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
python 在 Azure Pipelines 的“.py”中找不到“__main__”模塊
料青山看我應(yīng)如是
2023-05-16 14:59:19