【发布时间】:2020-03-23 03:09:26
【问题描述】:
我想知道是否有人有将python manage.py migrate 命令集成到 MS Azure 发布管道中的经验。该应用程序正在通过 DevOps 使用 CI/CD 管道进行部署。在发布管道部分,应用程序被部署到三个不同的阶段(开发、测试和生产)。我未能成功地将 migrate 命令集成到部署过程中。我已经尝试通过使用部署后内联脚本来实现这一点:
/antenv/bin/python /home/site/wwwroot/manage.py collectstatic
/antenv/bin/python /home/site/wwwroot/manage.py migrate
如果我通过 SSH 在沙盒环境中运行上述命令,它们将成功执行。 但是,将它们作为部署后脚本包含在发布管道中会引发以下错误:
2020-03-22T19:00:32.8641689Z Standard error from script:
2020-03-22T19:00:32.8727872Z ##[error]/home/site/VSTS_PostDeployment_1321584903618191/kuduPostDeploymentScript.sh: 1: /home/site/VSTS_PostDeployment_1321584903618191/kuduPostDeploymentScript.sh: /antenv/bin/python: not found
/home/site/VSTS_PostDeployment_1321584903618191/kuduPostDeploymentScript.sh: 2: /home/site/VSTS_PostDeployment_1321584903618191/kuduPostDeploymentScript.sh: /antenv/bin/python: not found
2020-03-22T19:01:34.3372528Z ##[error]Error: Unable to run the script on Kudu Service. Error: Error: Executed script returned '127' as return code. Error: /home/site/VSTS_PostDeployment_1321584903618191/kuduPostDeploymentScript.sh: 1: /home/site/VSTS_PostDeployment_1321584903618191/kuduPostDeploymentScript.sh: /antenv/bin/python: not found
/home/site/VSTS_PostDeployment_1321584903618191/kuduPostDeploymentScript.sh: 2: /home/site/VSTS_PostDeployment_1321584903618191/kuduPostDeploymentScript.sh: /antenv/bin/python: not found
我还尝试将上述内联脚本运行为:
manage.py collectstatic
manage.py migrate
但无济于事。
基于Oryx documentation,似乎manage.py collectstatic 正在运行,而不是manage.py migrate
任何想法或建议将不胜感激!提前致谢。
【问题讨论】:
标签: python django azure azure-devops kudu