// ## Jenkinsfile.wildfire.drupal-tests  Start the primary build-test-deploy job and just run drupal tests ##

pipeline {
  agent { label 'master' }
  parameters {
    string(name: 'DRUPAL_TEST', \
                 defaultValue: 'file websites/distro/web/modules/custom/wildfire_extra_tests/tests_drupal/drupal-tests', \
                 description: 'Drupal test to run.  For example: "file some-drupal-tests" or "phpunit modules/contrib/stepbystep/tests/src/Functional/StepByStepTest.php"')
    string(name: 'TEST_EMAIL_LIST', \
                 defaultValue: 'developers@kalaam.org', \
                 description: 'List of emails to notify with test results.')
  }
  options {
    buildDiscarder(logRotator(numToKeepStr:'5'))
    disableConcurrentBuilds()
    skipDefaultCheckout true
  }

  stages {

    stage('Start Build-Test-Deploy To Run Drupal Tests') {
      steps {
        echo 'Submit job ...'
        build wait: false, job: 'Wildfire-Build-Test-Deploy', parameters: [ \
          string(name: 'DO_LOCAL_TEST', value: "Yes"), \
          string(name: 'RUN_MODULE_TESTS', value: "false"), \
          string(name: 'RUN_DRUPAL_TESTS', value: "true"), \
          string(name: 'DRUPAL_TEST', value: params.DRUPAL_TEST), \
          string(name: 'DEV', value: ""), \
          string(name: 'TEST_EMAIL_LIST', value: params.TEST_EMAIL_LIST)]
        }
      }

    }

  post {
    always {
      echo 'always...'
    }
    success {
      echo 'success...'
//      mail to: "${EMAIL_LIST}",
//           subject: "SUCCESS: ${TEST_NAME}",
//           body: "See ${BUILD_URL}testReport for test results. ${EMAIL_COMMENT}"
    }
    unstable {
      echo 'unstable...'
//      mail to: "${EMAIL_LIST}",
//           subject: "FAILURE: ${TEST_NAME}",
//           body: "See ${BUILD_URL}testReport for test results. ${EMAIL_COMMENT}"
    }
    failure {
      echo 'failure...'
//      mail to: "michael@kalaam.org",
//           subject: "ERRORS: Build ${currentBuild.displayName}",
//           body: "See ${BUILD_URL} for build with errors."
    }
    changed {
      echo 'Something changed...'
    }

  }

}



