name: $(BuildID)_$(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)
variables:
  runCodesignValidationInjection: false
resources:
  containers:
  - container: linux-c-ubuntu-2004
    endpoint: csdk-containers
    image: csdkcontainerregistry.azurecr.io/linux-c-ubuntu-2004:latest
  - container: linux-c-ubuntu-clang
    endpoint: csdk-containers
    image: csdkcontainerregistry.azurecr.io/linux-c-ubuntu-clang:latest
  - container: linux-c-debian-buster
    endpoint: csdk-containers
    image: csdkcontainerregistry.azurecr.io/linux-c-debian-buster:latest
  - container: linux-c-ubuntu-wolfssl
    endpoint: csdk-containers
    image: csdkcontainerregistry.azurecr.io/linux-c-ubuntu-wolfssl:latest
  - container: raspberrypi-c-buster
    endpoint: csdk-containers
    image: csdkcontainerregistry.azurecr.io/raspberrypi-c-buster:brown
jobs:
- job: checksubmodule
  displayName: Check Submodules
  pool:
    vmImage: 'ubuntu-20.04'
  steps:
  - script: |
      sudo apt-get update && apt-get install -y \
      curl \
      git \
      python-software-properties \
      build-essential \
      pkg-config
      sudo curl -sL https://deb.nodesource.com/setup_16.x | bash -
      sudo apt-get install -y nodejs
    displayName: 'setup'
  - script: |
      npm install check_submodules
      node_modules/.bin/check_submodules . master
    displayName: 'build'
- job: windowsx86
  displayName: Windows x86
  pool:
    name: 'sdk-c--win-vs2022'
  steps:
  - script: |
     if exist jenkins\windows_c.cmd (
      call jenkins\windows_c_VsDevCmd.cmd
      call jenkins\windows_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)
- job: windowsx64
  pool:
    name: 'sdk-c--win-vs2022'
  displayName: 'Windows x64'
  steps:
  - script: |
     if exist jenkins\windows_c.cmd (
      call jenkins\windows_c_VsDevCmd.cmd
      call jenkins\windows_c.cmd --platform x64)
    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)
- job: windowsdynamic
  displayName: Windows Dynamic
  pool:
    name: 'sdk-c--win-vs2022'
  steps:
  - script: |
     if exist jenkins\windows_c_build_as_dynamic.cmd (
      call jenkins\windows_c_VsDevCmd.cmd
      call jenkins\windows_c_build_as_dynamic.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_CA_ROOT_CERT: $(IOTHUB-CA-ROOT-CERT)
      IOTHUB_CA_ROOT_CERT_KEY: $(IOTHUB-CA-ROOT-CERT-KEY)
      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)
- job: clang
  container: linux-c-ubuntu-clang
  pool: 
    name: 'sdk-c--ubuntu-22'
  displayName: 'Linux Ubuntu Clang'
  steps:
  - script: |
     if [ -f "jenkins/ubuntu_clang.sh" ]
     then
      export OPENSSL_ia32cap=0x00000000
      sudo chmod -R 755 .
      sudo -E ./jenkins/ubuntu_clang.sh
     fi
    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)
- job: linuxoptions
  container: linux-c-ubuntu-2004
  pool: 
    name: 'sdk-c--ubuntu-22'
  displayName: 'Linux Ubuntu 20.04 with Options'
  steps:
  - script: |
     if [ -f "jenkins/linux_c_option_test.sh" ]
     then
      sudo ./jenkins/linux_c_option_test.sh
     fi
    displayName: 'build'
    condition: always()
- job: wolfssl
  container: linux-c-ubuntu-wolfssl
  pool: 
    name: 'sdk-c--ubuntu-22'
  displayName: 'Linux Ubuntu with WolfSSL'
  steps:
  - script: |
     if [ -f "jenkins/linux_wolfssl.sh" ]
     then
      LD_LIBRARY_PATH=/usr/local/lib
      LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/my_library/
      sudo ./jenkins/linux_wolfssl.sh
     fi
    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)
- job: debian
  container: linux-c-debian-buster
  pool: 
    name: 'sdk-c--ubuntu-22'
  displayName: 'Linux Debian (Buster)'
  steps:
  - script: |
     if [ -f "jenkins/debian_c.sh" ]
     then
      sudo chmod 755 jenkins/debian_c.sh
      sudo -E ./debian_c.sh
      sudo jenkins/debian_c.sh
     fi
    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)
- job: linux_install_deps
  container: linux-c-debian-buster
  pool: 
    name: 'sdk-c--ubuntu-22'
  displayName: 'Linux Debian (Buster) with Installed Deps'
  steps:
  - script: |
     if [ -f "jenkins/linux_install_deps.sh" ]
     then
      sudo chmod 755 jenkins/linux_install_deps.sh
      sudo -E ./jenkins/linux_install_deps.sh
      sudo jenkins/linux_install_deps.sh
     fi
    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)
- job: OSX
  displayName: OSX
  variables:
    CodeQL.Enabled: false
  pool:
    vmImage: 'macOS-13'
  steps:
  - script: |
     if [ -f "jenkins/osx_gcc_openssl.sh" ]
     then
      ./jenkins/osx_gcc_openssl.sh
     fi
    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)
- job: xcodenative
  displayName: XCode Native
  variables:
    CodeQL.Enabled: false
  pool:
    vmImage: 'macOS-13'
  steps:
  - script: |
     if [ -f "jenkins/osx_xcode_native.sh" ]
     then
      DYLD_LIBRARY_PATH=/usr/local/Cellar/curl/7.61.0/lib
      ./jenkins/osx_xcode_native.sh
     fi
    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)
- job: raspberrypi
  container: raspberrypi-c-buster
  pool: 
    name: 'sdk-c--ubuntu-22'
  displayName: Raspberry Pi
  steps:
  - script: |
     chmod +x jenkins/raspberrypi_c_buster.sh
     ./jenkins/raspberrypi_c_buster.sh
    displayName: 'build'

