Might be a very dumb question, but I cannot see any solutions as of now.
I configured a Jenkins server to checkout my Laravel5 project from Git repo. I see by default there is .env excluded in .gitignore, but .env.example will be under source control...So of course after Jenkins check the project out, there is no .env file and PhpUnit execution fails, because there is also no encryption key etc... So what is the best method to automatically get a valid .env into the Jenkins workspace?
"If the APP_ENV environment variable is set before bootstrapping the application, Laravel will attempt to load a file that matches the environment. For example, if the PHPUnit configuration file sets the APP_ENV variable to testing, Laravel will attempt to load an .env.testing environment file. If the file does not exist, the default .env file is loaded."
Then you just need to commit the testing env file with your project. Make sure that if you are doing any tests with any sort of production collaborator (an external service etc.), that you either use very locked down / rate limited accounts, or pass these variables via Jenkins config itself.
But isn't it bad practice to commit .env files, even if only for test env, because of confidential data in the .env file, like username/password? How can one assure that confidential connection data don't get abused when under source control?