Azure pipeline build Stage verification

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-29 14:52:59

问题


As a centralized azure devops team in my org , we want to ensure that code of certain technology type built using standard extended yaml template. Thanks to the "Extend" feature and recently introduced template check at environment level , we are now able to verify developers yamls if they are extending our standard yamls or not. But this check only runs after build stage. Can we somehow evaluate this before build stage?


回答1:


Can we somehow evaluate this before build stage?

I'm afraid, no, it can not be true until now especially your company is very strict on YAML structure check.


Until now, Environment can only be target in deployment job of YAML.

In another word, only the stage that configure the - deployment: job in it, can work with Environment.

If your company policy allow, in fact, here the work around is adding - deployment: job into Build stage but leave the steps as blank. Sample like this:

  - 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

This can actual do what you want. BUT I'm afraid your policy would not allow this.



来源:https://stackoverflow.com/questions/60518892/azure-pipeline-build-stage-verification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!