为基于 Django 的 API 开发 CI/CD 管道。我需要在构建阶段注入环境变量才能成功构建图像。
python manage.py collectstaticDockerfile在构建映像时运行collectstatic需要SECRET_KEY在settings.py运行SECRET_KEY在此阶段为空,因为它是用os.environ['SECRET_KEY]我无法将这么多内容放在一起,所以想看看是否有人可以帮助我。
这是我到目前为止所拥有的:
Azure管道
azure-pipelines.yml
trigger:
branches:
include:
- master
resources:
- repo: self
variables:
# Container registry service connection established during pipeline creation
secretKey: $(SECRET_KEY)
# Agent VM image name
vmImageName: 'ubuntu-latest'
stages:
- stage: Build
displayName: Build and push stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- bash:
env:
SECRET_KEY: $(secretKey)
- …Run Code Online (Sandbox Code Playgroud)