#################################################################################
#                           Onebranch Retail Pipeline                           #
# This pipeline was created by EasyStart from a sample located at:              #
#   https://aka.ms/obpipelines/easystart/samples                                #
# Documentation:  https://aka.ms/obpipelines                                    #
# Yaml Schema:    https://aka.ms/obpipelines/yaml/schema                        #
# Retail Tasks:   https://aka.ms/obpipelines/tasks                              #
# Support:        https://aka.ms/onebranchsup                                   #
#################################################################################

trigger: none # Trigger is managed through ADO Pipelines registration UI

parameters: # parameters are shown up in ADO UI in a build queue time
  - name: "debug"
    displayName: "Enable debug output"
    type: boolean
    default: false

variables:
  - name: CDP_DEFINITION_BUILD_COUNT
    value: $[counter('', 0)] # needed for onebranch.pipeline.version task https://aka.ms/obpipelines/versioning
  - name: system.debug
    value: ${{ parameters.debug }}
  - name: WindowsContainerImage
    value: "onebranch.azurecr.io/windows/ltsc2022/vse2022:latest" # Docker image which is used to build the project https://aka.ms/obpipelines/containers
  - name: LinuxContainerImage
    value: "mcr.microsoft.com/onebranch/azurelinux/build:3.0"

resources:
  repositories:
    - repository: templates
      type: git
      name: OneBranch.Pipelines/GovernedTemplates
      ref: refs/heads/main

extends:
  template: v2/OneBranch.Official.CrossPlat.yml@templates
  parameters:
    git:
      fetchDepth: 1

    featureFlags:
      LinuxHostVersion:
        Network: KS1
      WindowsHostVersion:
        Network: KS1

    cloudvault: # https://aka.ms/obpipelines/cloudvault
      enabled: false
    globalSdl: # https://aka.ms/obpipelines/sdl
      tsa:
        enabled: false # onebranch publish all sdl results to TSA. If TSA is disabled all SDL tools will forced into 'break' build mode.
      codeql:
        cadence: 72 # recommended default, in hours, between new scan databases created
        tsaEnabled: true

      policheck:
        break: true # always break the build on policheck issues. You can disable it by setting to 'false'
      perStage:
        sdl_sources:
          checkout_all_repos: true

    stages:
    - stage: Build
      jobs:

      - job: initialize_build
        pool:
          type: linux

        variables:
          ob_outputDirectory: "$(Build.ArtifactStagingDirectory)" # REQUIRED even if not used: this directory is uploaded to pipeline artifacts, reddog and cloudvault. More info at https://aka.ms/obpipelines/artifacts

        steps:
          - task: onebranch.pipeline.version@1 # generates automatic version. For other versioning options check https://aka.ms/obpipelines/versioning
            displayName: "Setup Build Number"
            inputs:
              system: "RevisionCounter"
              major: "1"
              minor: "0"
              exclude_commit: true
            enabled: true