我的目標是通過 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
1 回答

狐的傳說
TA貢獻1804條經驗 獲得超3個贊
您無法獲取源代碼的原因是因為您用于download: current
下載當前管道運行產生的工件,但您沒有在當前管道中發布任何工件。
由于部署作業不會自動簽出源代碼,您需要在部署作業中簽出源代碼,
???????-?checkout:?self
或者在下載之前將源發布到工件。
??????-?publish:?$(Build.SourcesDirectory) ??????????????artifact:?Artifact_Deploy
添加回答
舉報
0/150
提交
取消