Azure 管道构建阶段验证
Azure pipeline build Stage verification
作为我组织中的集中式 azure devops 团队,我们希望确保使用标准扩展 yaml 模板构建特定技术类型的代码。由于 "Extend" 功能和最近在环境级别引入的模板检查,我们现在能够验证开发人员是否扩展了我们的标准 yaml。但是这个检查只在构建阶段之后运行。我们可以在构建阶段之前以某种方式对此进行评估吗?
Can we somehow evaluate this before build stage?
恐怕,不,直到现在都不可能是真的,尤其是贵公司对 YAML 结构检查非常严格。
到目前为止,Environment
只能是YAML的deployment job
中的target。
换句话说,只有在其中配置了- deployment:
作业的阶段,才能与Environment
一起工作。
如果您的公司政策允许,实际上,这里的解决方法是将 - deployment:
作业添加到 Build
阶段,但将步骤留空。示例如下:
- stage: build
jobs:
- job: buildjob
steps:
- checkout: none
- task: oneLuckiGetPostmanScripts@1
inputs:
fileLocation: '$(Build.ArtifactStagingDirectory)/postman'
apiKey: '$(postmankey)'
- deployment: DeployWeb
pool:
vmImage: 'Ubuntu-16.04'
# creates an environment if it doesn't exist
environment: 'Verify'
- stage: test
jobs:
- job: testjob
steps:
- checkout: none
- bash: |
echo $(Build.ArtifactStagingDirectory)/postman
displayName: 'dir'
- stage: deploy
jobs:
- deployment: DeployWeb
displayName: deploy Web App
pool:
vmImage: 'Ubuntu-16.04'
# creates an environment if it doesn't exist
environment: 'Verify'
strategy:
runOnce:
deploy:
steps:
- script: echo my first deployment
这实际上可以做你想做的事。但恐怕您的政策不允许这样做。
作为我组织中的集中式 azure devops 团队,我们希望确保使用标准扩展 yaml 模板构建特定技术类型的代码。由于 "Extend" 功能和最近在环境级别引入的模板检查,我们现在能够验证开发人员是否扩展了我们的标准 yaml。但是这个检查只在构建阶段之后运行。我们可以在构建阶段之前以某种方式对此进行评估吗?
Can we somehow evaluate this before build stage?
恐怕,不,直到现在都不可能是真的,尤其是贵公司对 YAML 结构检查非常严格。
到目前为止,Environment
只能是YAML的deployment job
中的target。
换句话说,只有在其中配置了- deployment:
作业的阶段,才能与Environment
一起工作。
如果您的公司政策允许,实际上,这里的解决方法是将 - deployment:
作业添加到 Build
阶段,但将步骤留空。示例如下:
- stage: build
jobs:
- job: buildjob
steps:
- checkout: none
- task: oneLuckiGetPostmanScripts@1
inputs:
fileLocation: '$(Build.ArtifactStagingDirectory)/postman'
apiKey: '$(postmankey)'
- deployment: DeployWeb
pool:
vmImage: 'Ubuntu-16.04'
# creates an environment if it doesn't exist
environment: 'Verify'
- stage: test
jobs:
- job: testjob
steps:
- checkout: none
- bash: |
echo $(Build.ArtifactStagingDirectory)/postman
displayName: 'dir'
- stage: deploy
jobs:
- deployment: DeployWeb
displayName: deploy Web App
pool:
vmImage: 'Ubuntu-16.04'
# creates an environment if it doesn't exist
environment: 'Verify'
strategy:
runOnce:
deploy:
steps:
- script: echo my first deployment
这实际上可以做你想做的事。但恐怕您的政策不允许这样做。