name: $(BuildID)_$(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)
variables:
  runCodesignValidationInjection: false
resources:
- repo: self
  clean: true
jobs:
- job: longhaul_linux
  timeoutInMinutes: 800
  variables:
    _PREVIEW_VSTS_DOCKER_IMAGE: "aziotbld/linux-c-ubuntu"
  pool: 
    name: 'aziotbld-lin01'
  displayName: 'longhaul_linux'
  steps:
  - script: |
      sudo chmod 755 jenkins/longhaul_c.sh
      sudo -E ./jenkins/longhaul_c.sh
    displayName: 'build'
    env:
      IOTHUB_CONNECTION_STRING: $(IOTHUB-CONNECTION-STRING)
      IOTHUB_EVENTHUB_CONNECTION_STRING: $(IOTHUB-EVENTHUB-CONNECTION-STRING)
      IOTHUB_E2E_X509_CERT_BASE64: $(IOTHUB-E2E-X509-CERT-BASE64)
      IOTHUB_E2E_X509_PRIVATE_KEY_BASE64: $(IOTHUB-E2E-X509-PRIVATE-KEY-BASE64)
      IOTHUB_E2E_X509_THUMBPRINT: $(IOTHUB-E2E-X509-THUMBPRINT)
      IOTHUB_POLICY_KEY: $(IOTHUB-POLICY-KEY)
      IOTHUB_PARTITION_COUNT: $(IOTHUB-PARTITION-COUNT)
      STORAGE_ACCOUNT_CONNECTION_STRING: $(STORAGE-ACCOUNT-CONNECTION-STRING)
      IOT_DPS_CONNECTION_STRING: $(IOT-DPS-CONNECTION-STRING)
      IOT_DPS_ID_SCOPE: $(IOT-DPS-ID-SCOPE)
      IOTHUB_CA_ROOT_CERT: $(IOTHUB-CA-ROOT-CERT)
      IOTHUB_CA_ROOT_CERT_KEY: $(IOTHUB-CA-ROOT-CERT-KEY)
      IOT_DPS_GLOBAL_ENDPOINT: $(IOT-DPS-GLOBAL-ENDPOINT)
      IOTHUB_DEVICE_CONN_STRING_INVALIDCERT: $(IOTHUB-DEVICE-CONN-STRING-INVALIDCERT)
      IOTHUB_CONN_STRING_INVALIDCERT: $(IOTHUB-CONN-STRING-INVALIDCERT)
      DPS_GLOBALDEVICEENDPOINT_INVALIDCERT: $(DPS-GLOBALDEVICEENDPOINT-INVALIDCERT)
      PROVISIONING_CONNECTION_STRING_INVALIDCERT: $(PROVISIONING-CONNECTION-STRING-INVALIDCERT)
  - script: sudo rm -rf $(Agent.BuildDirectory)/*
    displayName: 'cleanup'
    condition: always()
- job: longhaul_windows
  timeoutInMinutes: 800
  pool:
    name: 'aziotbld-win10'
  steps:
  - script: |
      call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat"
      call jenkins\longhaul_c.cmd
    displayName: 'build'
    env:
      IOTHUB_CONNECTION_STRING: $(IOTHUB-CONNECTION-STRING)
      IOTHUB_EVENTHUB_CONNECTION_STRING: $(IOTHUB-EVENTHUB-CONNECTION-STRING)
      IOTHUB_E2E_X509_CERT_BASE64: $(IOTHUB-E2E-X509-CERT-BASE64)
      IOTHUB_E2E_X509_PRIVATE_KEY_BASE64: $(IOTHUB-E2E-X509-PRIVATE-KEY-BASE64)
      IOTHUB_E2E_X509_THUMBPRINT: $(IOTHUB-E2E-X509-THUMBPRINT)
      IOTHUB_POLICY_KEY: $(IOTHUB-POLICY-KEY)
      IOTHUB_PARTITION_COUNT: $(IOTHUB-PARTITION-COUNT)
      STORAGE_ACCOUNT_CONNECTION_STRING: $(STORAGE-ACCOUNT-CONNECTION-STRING)
      IOT_DPS_CONNECTION_STRING: $(IOT-DPS-CONNECTION-STRING)
      IOT_DPS_ID_SCOPE: $(IOT-DPS-ID-SCOPE)
      IOTHUB_DEVICE_CONN_STRING_INVALIDCERT: $(IOTHUB-DEVICE-CONN-STRING-INVALIDCERT)
      IOTHUB_CONN_STRING_INVALIDCERT: $(IOTHUB-CONN-STRING-INVALIDCERT)
      DPS_GLOBALDEVICEENDPOINT_INVALIDCERT: $(DPS-GLOBALDEVICEENDPOINT-INVALIDCERT)
      PROVISIONING_CONNECTION_STRING_INVALIDCERT: $(PROVISIONING-CONNECTION-STRING-INVALIDCERT)
  - script: cd .. && rd /Q /S $(Agent.BuildDirectory)\s
    displayName: 'cleanup'
    condition: always() 
