/** * {@inheritdoc} */ public function run(JobInterface $job, $data = NULL) { // Get and parse test definitions // DrupalCI jobs are controlled via a hierarchy of configuration settings, which define the behaviour of the platform while running DrupalCI jobs. This hierarchy is defined as follows, which each level overriding the previous: // 1. Out-of-the-box DrupalCI defaults // 2. Local overrides defined in ~/.drupalci/config // 3. 'DCI_' namespaced environment variable overrides // 4. Test-specific overrides passed inside a DrupalCI test definition (e.g. .drupalci.yml) // 5. Custom overrides located inside a test definition defined via the $source variable when calling this function. $confighelper = new ConfigHelper(); // Load job defaults $platform_args = $job->getPlatformDefaults(); $default_args = $job->getDefaultArguments(); if (!empty($default_args)) { $job->getOutput()->writeln("<comment>Loading build variables for this job type.</comment>"); } // Load DrupalCI local config overrides $local_args = $confighelper->getCurrentConfigSetParsed(); if (!empty($local_args)) { $job->getOutput()->writeln("<comment>Loading build variables from DrupalCI local config overrides.</comment>"); } // Load "DCI_ namespaced" environment variable overrides $environment_args = $confighelper->getCurrentEnvVars(); if (!empty($environment_args)) { $job->getOutput()->writeln("<comment>Loading build variables from namespaced environment variable overrides.</comment>"); } // Load command line arguments // TODO: Routine for loading command line arguments. // TODO: How do we pull arguments off the drupalci command, when in a job class? // $cli_args = $somehelper->loadCLIargs(); $cli_args = array(); if (!empty($cli_args)) { $job->getOutput()->writeln("<comment>Loading test parameters from command line arguments.</comment>"); } // Create temporary config array to use in determining the definition file source $config = $cli_args + $environment_args + $local_args + $default_args + $platform_args; // Load any build vars defined in the job definition file // Retrieve test definition file if (isset($source)) { $config['explicit_source'] = $source; } $definition_file = $this->getDefinitionFile($config); $definition_args = array(); // Load test definition file if (!empty($definition_file)) { $job->getOutput()->writeln("<comment>Loading test parameters from build file: </comment><info>{$definition_file}</info>"); $jobdef = new JobDefinition(); $result = $jobdef->load($definition_file); if ($result == -1) { // Error loading definition file. $job->errorOutput("Failed", "Unable to parse build file."); // TODO: Robust error handling return; } $job_definition = $jobdef->getParameters(); if (empty($job_definition)) { $job_definition = array(); $definition_args = array(); } else { $definition_args = !empty($job_definition['build_vars']) ? $job_definition['build_vars'] : array(); } $job->setDefinition($job_definition); } $config = $cli_args + $definition_args + $environment_args + $local_args + $default_args + $platform_args; // Set initial build variables $buildvars = $job->getBuildVars(); $job->setBuildVars($buildvars + $config); // Map relevant build variables into the job definition array // $this->buildvarsToDefinition($job); return; }