使用Bitbucket Pipelines+Deployer7部署Shopware6.5遇故障求助
部署Shopware 6.5时Bitbucket Pipelines + Deployer7的问题排查与解决思路
问题背景
通过Bitbucket Pipelines结合Deployer7部署Shopware6.5,提交代码后流水线可执行,但deploy.php中部分任务出现异常。
初始配置与首次报错
最初的Shopware任务配置如下:
task('sw:deploy', [ 'sw:touch_install_lock', 'sw:build', 'sw:database:migrate', 'sw:theme:compile', 'sw:cache:clear', ]);
执行时sw:build任务中的run('cd {{release_path}} && bash bin/build-js.sh');语句报错,推测该命令需要数据库支持,因此移除该命令,改用deployer/recipe/shopware.php中的部分任务调整配置。
调整后的配置与新错误
调整后的deploy.php配置:
task('sw:deploy', [ 'sw:touch_install_lock', 'sw:database:migrate', 'sw:theme:compile', 'sw:cache:clear', ]); task('sw-build-without-db:get-remote-config', static function () { if (!test('[ -d {{current_path}} ]')) { return; } within('{{deploy_path}}/current', function () { run('{{bin/php}} ./bin/console bundle:dump'); download('{{deploy_path}}/current/var/plugins.json', './var/'); run('{{bin/php}} ./bin/console theme:dump'); download('{{deploy_path}}/current/files/theme-config', './files/'); }); }); task('sw-build-without-db:build', static function () { runLocally('CI=1 SHOPWARE_SKIP_BUNDLE_DUMP=1 SHOPWARE_SKIP_THEME_COMPILE=1 bin/build-js.sh'); }); task('sw-build-without-db', [ 'sw-build-without-db:get-remote-config', 'sw-build-without-db:build', ]); before('deploy:update_code', 'sw-build-without-db');
调整后出现新错误:
[localhost] run CI=1 SHOPWARE_SKIP_BUNDLE_DUMP=1 SHOPWARE_SKIP_THEME_COMPILE=1 bin/build-js.sh [localhost] Cannot check extensions for required npm installations as jq is not installed [localhost] /opt/atlassian/pipelines/agent/build/bin/build-administration.sh: line 53: cd: /opt/atlassian/pipelines/agent/build/vendor/shopware/administration/Resources/app/administration: No such file or directory [server.de] error in deploy.php on line 106: [server.de] exit code 1 (General error) done sw-build-without-db:build 91ms ERROR: Task sw-build-without-db:build failed!
已在本地Macbook安装jq但错误仍存在,同时Bitbucket Pipelines中出现Docker相关警告:
time="2023-07-13T13:33:00.176324092Z" level=warning msg="could not change group /var/run/docker.sock to docker: group docker not found" time="2023-07-13T13:33:00.176761183Z" level=warning msg="Binding to IP address without --tlsverify is insecure and gives root access on this machine to everyone who has access to your network." host="tcp://0.0.0.0:2375" time="2023-07-13T13:33:00.176825537Z" level=warning msg="Binding to an IP address, even on localhost, can also give access to scripts run in a browser. Be safe out there!" host="tcp://0.0.0.0:2375"
解决思路
1. 修复jq未安装的问题
本地Mac安装jq无效,因为报错发生在Bitbucket Pipelines的Agent环境中,需在Pipeline的运行环境里安装jq:
- 如果使用Debian/Ubuntu系镜像,在
bitbucket-pipelines.yml的步骤中添加:apt-get update && apt-get install -y jq - 如果是Alpine系镜像,添加:
apk add --no-cache jq
2. 解决vendor目录缺失的问题
错误提示找不到vendor/shopware/administration目录,说明执行build-js.sh前未安装Composer依赖:
- 在
sw-build-without-db:build任务中,先执行Composer安装命令:
task('sw-build-without-db:build', static function () { runLocally('composer install --no-dev --optimize-autoloader'); runLocally('CI=1 SHOPWARE_SKIP_BUNDLE_DUMP=1 SHOPWARE_SKIP_THEME_COMPILE=1 bin/build-js.sh'); });
- 或者在
bitbucket-pipelines.yml的前置步骤中完成Composer依赖安装,确保Agent环境中有完整的vendor目录。
3. Docker警告的处理
这些警告属于Docker daemon配置问题,不影响Shopware部署任务的执行,若需处理:
- 针对
group docker not found:在Pipeline使用的Docker镜像中提前创建docker组,或调整/var/run/docker.sock的权限 - 针对无TLS验证的端口绑定:修改Docker配置,仅绑定
127.0.0.1而非0.0.0.0,或启用TLS验证。若只是部署使用,可暂时忽略该警告。
4. 部署流程优化建议
- 将前端构建(
build-js.sh)放在Bitbucket Pipelines的独立步骤中完成,而非通过Deployer的runLocally,便于单独调试和拆分任务 - 确保Pipeline环境预装所有依赖工具:PHP、Composer、Node.js、npm/yarn、jq等
- 参考Shopware官方部署文档,确认构建步骤的依赖顺序和环境要求
内容的提问来源于stack exchange,提问作者Gunnarius
相关产品推荐
相关产品推荐

