Forked from CarterZhou/pipeline-of-installing-and-testing-laravel-application
Created
July 30, 2020 16:48
-
-
Save anilkrs09/a0df7cd0f56d0ac432038d4570ac47cf to your computer and use it in GitHub Desktop.
This is a sample script of installing and testing a Laravel application using Jenkins pipeline
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node { | |
stage('download') { | |
git branch: 'master', url: 'github/url/to/your/project' | |
} | |
stage('install') { | |
sh 'composer install' | |
} | |
stage('init') { | |
sh 'cp .env.example .env' | |
sh 'php artisan key:generate' | |
sh "sed -i -e 's/DB_DATABASE=homestead/DB_DATABASE=staging/g' .env" | |
sh "sed -i -e 's/DB_USERNAME=homestead/DB_USERNAME=yourusername/g' .env" | |
sh "sed -i -e 's/DB_PASSWORD=secret/DB_PASSWORD=yourpassword/g' .env" | |
} | |
stage('integration_testing') { | |
sh 'vendor/bin/phpunit tests/Feature' | |
} | |
stage('acceptance_testing') { | |
// Because we'll use database as session driver during testing, we have to explictly migrate sessions table. | |
sh 'php artisan migrate' | |
sh 'cp .env .env.dusk.local' | |
sh "sed -i -e 's;APP_URL=http://localhost;APP_URL=your.domain.com;g' .env.dusk.local" | |
// Use database as session driver instead of file so that every single test will not share the same session context. | |
sh "sed -i -e 's/SESSION_DRIVER=file/SESSION_DRIVER=database/g' .env.dusk.local" | |
// Allow web server to access storage directory. | |
sh 'sudo chmod -R 775 storage/' | |
sh 'sudo chown -R :www-data storage/' | |
sh 'php artisan dusk' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment