Welcome Guest, Not a member yet? Register   Sign In
gitlab CI/CD pipeline cannot run php spark
#2

Found the problem in CodeIgniter.php file, detectEnvironment() function.

PHP Code:
protected function detectEnvironment()
{
    
// Make sure ENVIRONMENT isn't already set by other means.
    
if (! defined('ENVIRONMENT'))
    {
        
// running under Continuous Integration server?
        
if (getenv('CI') !== false)
        {
            
define('ENVIRONMENT''testing');
        }
        else
        {
            
define('ENVIRONMENT'$_SERVER['CI_ENVIRONMENT'] ?? 'production');
        }
    }


When we run under CI server, we will always get ENVIRONMENT = testing.

Testing environment can't get clirequest in getRequestObject() function if we run it in cli.

PHP Code:
protected function getRequestObject()
{
    if (
$this->request instanceof Request)
    {
        return;
    }

    if (
is_cli() && ENVIRONMENT !== 'testing')
    {
        
// @codeCoverageIgnoreStart
        
$this->request Services::clirequest($this->config);
        
// @codeCoverageIgnoreEnd
    
}
    else
    {
        
$this->request Services::request($this->config);
        
// guess at protocol if needed
        
$this->request->setProtocolVersion($_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.1');
    }


It means we dont have flexibility to change/use custom ENVIRONMENT in CI/CD server.

Can i request to remove the code that always set ENVIRONMENT = testing in CI/CD server?
or
request to allow testing environment to get/use clirequest?
Reply


Messages In This Thread
RE: gitlab CI/CD pipeline cannot run php spark - by adty - 08-11-2020, 09:06 PM



Theme © iAndrew 2016 - Forum software by © MyBB