git post-receive hook +定义环境变量

时间:2017-04-02 06:44:06

标签: mysql git bash environment-variables hook

我正在使用收件后HOOK进行Git部署?目标是设置代码,以便可以毫无问题地进行部署。我遇到的问题是必须正确定义环境变量,否则事情(如数据库)将失败 - 如下所示。

如何在后接收Hook for Git中定义环境变量?

TIA

收到后文件:

[... snip ...]

if [ "prod" == "$branch" ]; then
    git --work-tree=$target_directory checkout -f prod
fi

CUR_TIME=`date +%Y-%m-%d:%H:%M:%S`
echo "$CUR_TIME CD to the target directory $target_directory and complete the actions" >> $LOGFILE
cd $target_directory

composer='which composer'

CUR_TIME=`date +%Y-%m-%d:%H:%M:%S`
echo "$CUR_TIME Remove items from cache and view areas" >> $LOGFILE
rm -f storage/cache/*
echo "storage cache cleared for $target_directory"

rm -f storage/views/*
echo "storage views cleared for $target_directory"

#remove compiled cache files if they exist
rm -f bootstrap/compiled.php
rm -f app/storage/meta/services.json

# install packages, this also regenerates the autoloader
$composer install --no-scripts --no-dev --no-interaction --prefer-dist
#$composer install

# Ensure that storage's folder have write permission for the group
chmod -R g+w storage

#fixing permissions for files that got disturbed along the way
chown -R $(users):$(users) .
find . -type d -exec chmod 0755 {} \; && find . -type f -exec chmod 0644 {} \;

# run any outstanding migrations
$php artisan migrate --force

# optimize autoloader and compile common classes
$php artisan optimize --force

$php artisan config:cache

$php artisan route:cache


[... snip ...]

日志(我收到此错误)

remote:   - Installing league/flysystem (1.0.35): Loading from cache
remote:   - Installing laravel/framework (v5.4.15): Loading from cache
remote:   - Installing laravel/tinker (v1.0.0): Loading from cache
remote: Generating autoload files
remote: Current application environment: production
remote:
remote:
remote:   [Illuminate\Database\QueryException]
remote:   SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using pa
remote:   ssword: NO) (SQL: select * from information_schema.tables where table_schem
remote:   a = forge and table_name = migrations)
remote:
remote:
remote:
remote:   [PDOException]
remote:   SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using pa
remote:   ssword: NO)
remote:
remote:
remote: Generating optimized class loader
remote: The compiled services file has been removed.
remote: Configuration cache cleared!
remote: Configuration cached successfully!
remote: Route cache cleared!
remote:
remote:
remote:   [LogicException]
remote:   Unable to prepare route [api/user] for serialization. Uses Closure.
remote:

0 个答案:

没有答案
相关问题