Last active
March 28, 2024 17:05
-
-
Save CarterZhou/76ae74021c7d73e3fbeeb4a0c10e254f 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
does in this case Jenkins and Laravel live on the same server? coz i don't see the step for uploading the app.