Our php artisan migrate fails without a clear error on screen .So I want to tail the laravel log afterwards. But the script calls the teardown without the laravel log....
How can I tail logs after the build fails?
My bitbucket-pipelines
image: php:7.1.1
pipelines:
default:
- step:
services:
- mysql
deployment: test
caches:
- composer
script:
- apt-get update && apt-get install -y unzip
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
- docker-php-ext-install pdo_mysql
- cp php.ini /usr/local/etc/php/php.ini
- composer install
- php -r "copy('.env.testing', '.env');"
- php --ini
- ls /usr/local/etc/php/
- export DB_CONNECTION=mysql
- composer dump-autoload
- php artisan migrate:install
- php artisan cache:clear
- php artisan migrate
- tail storage/logs/laravel.log -n 100
definitions:
services:
mysql:
image: mysql:5.7.22
entrypoint: ['/entrypoint.sh', '--character-set-server=utf8', '--collation-server=utf8_general_ci']
environment:
MYSQL_DATABASE: '********'
MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
MYSQL_USER: '***********'
MYSQL_PASSWORD: '************'
Hey @Marten van Urk,
the simplest way is to combine the two commands using the bash built-in ||
- php artisan migrate || tail storage/logs/laravel.log -n 100
the downside is the exit code is lost, meaning your build will always pass.
If you want to keep this and track the exit code, the command is a bit uglier.
bash -c 'php artisan migrate; RET=$?; tail storage/logs/laravel.log -n 100; exit $RET'
Hope that helps,
Seb
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.