0

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?

enter image description here

Sanjeev
  • 415
  • 5
  • 17

1 Answers1

0

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.

Mengdi Liang
  • 17,577
  • 2
  • 28
  • 35
  • Great workaround, added a YAML compliance stage in pipeline which is a deployment stage before the build , created a "verify" environment , added extend template check in there and it works as expected. Only thing that seems still out of control is teams can still create their own pipeline yaml , the perfect solution would be to hook up this verify stage on any build invocation – Sanjeev Mar 05 '20 at 03:38
  • @Sanjeev, yeap, you are right. As I said, its limitation is only work for one stage. So, if you want to check all, you must let it defined in every stage to make this extend checked work for all. – Mengdi Liang Mar 05 '20 at 03:42