#!groovy

pipeline {
  agent none

  environment {
    PROJECT_TEST_CONFIG_DIR = "/.ci/monitarr/test_config"
  }

  options {
    disableConcurrentBuilds()
    retry(2)
  }

  stages {
    stage('linux_x86_64') {
      agent any

      steps {
        retry(2) {
          sleep time: 5, unit: 'SECONDS'
          sh 'scripts/make_unix.sh'
        }
      }
    }

    stage('mingw64') {
      agent any

      steps {
        retry(2) {
          sleep time: 5, unit: 'SECONDS'
          sh 'scripts/make_win32.sh'
        }
      }
    }

    stage('linux_aarch64') {
      agent any

      steps {
        retry(2) {
          sleep time: 5, unit: 'SECONDS'
          sh 'scripts/make_unix.sh aarch64'
        }
      }
    }

    stage('test') {
      agent any

      steps {
        sh 'scripts/test.sh'
        sh 'scripts/test.sh "" "" "" "" 1 1'
        sh 'scripts/test.sh aarch64'
      }
    }

    stage('deliver') {
      agent any

      steps {
        sh 'scripts/deliver.sh /mnt/monitarr "" "" "" "" 1 1'
        sh 'scripts/deliver.sh /mnt/monitarr "" aarch64'
        sh 'scripts/deliver.sh /mnt/monitarr'
      }
    }
  }
}
