如何在 gitlab-ci.yml 中使用 drush 作为服务?
How to use drush as a service in gitlab-ci.yml?
根据 the documentation 我正在尝试在 gitlab-ci.yml.
中添加 drush
这是我的gitlab的顶层-ci.yml:
image: tetraweb/php:7.1
services:
- drush/drush:8
但显然服务没有正常启动:
Running with gitlab-runner 10.8.0 (079aad9e)
on docker-runner 8a1645e0
Using Docker executor with image teamdesk/toolbox:7.2 ...
Starting service drush/drush:8 ...
Pulling docker image drush/drush:8 ...
Using docker image sha256:646ef48a637011d5bf97ed3021e280d583aa966e63fceea478d9be8dc5ea2902 for drush/drush:8 ...
Waiting for services to be up and running...
*** WARNING: Service runner-8a1645e0-project-35-concurrent-0-drush__drush-0 probably didn't start properly.
Health check error:
exit code 1
Health check container logs:
2019-03-07T16:51:12.703254779Z No HOST or PORT
如果我尝试以下操作:
services:
- name: drush/drush:8
command: ["drush", "config-import -y"]
我得到:
Running with gitlab-runner 10.8.0 (079aad9e)
on docker-runner e0df35ff
Using Docker executor with image teamdesk/toolbox:7.2 ...
Starting service drush/drush:8 ...
Pulling docker image drush/drush:8 ...
Using docker image sha256:646ef48a637011d5bf97ed3021e280d583aa966e63fceea478d9be8dc5ea2902 for drush/drush:8 ...
Waiting for services to be up and running...
*** WARNING: Service runner-e0df35ff-project-35-concurrent-0-drush__drush-0 probably didn't start properly.
Health check error:
exit code 1
Health check container logs:
2019-03-08T08:37:07.739033180Z No HOST or PORT
Service container logs:
2019-03-08T08:37:07.398595623Z The drush command 'drush config-import -y' could not be found. Run [error]
2019-03-08T08:37:07.398686996Z `drush cache-clear drush` to clear the commandfile cache if you have
2019-03-08T08:37:07.398695300Z installed new extensions.
因为我需要 运行 drush updatedb
和 drush config-import
在生产服务器上部署之前,我想在 gitlab 中使用 drush 作为服务- ci.yml.
drush config-import -y
是一次性命令;一旦它的工作完成,它 运行s 的过程就会停止。所以它不是服务,你不能把它放在 .gitlab-ci.yml
的 service:
部分。 Gitlab CI Runner 希望这些服务永远不会停止,并且如果其中一项服务死亡,将会抱怨。
你能做什么?
运行 drush
在 script:
部分。为此,您必须确保 docker 图像 tetraweb/php:7.1
具有可用的 drush
命令。
image: tetraweb/php:7.1 ## this image must have drush available
script:
- drush config-import -y
- drush updatedb
...
根据 the documentation 我正在尝试在 gitlab-ci.yml.
中添加 drush这是我的gitlab的顶层-ci.yml:
image: tetraweb/php:7.1
services:
- drush/drush:8
但显然服务没有正常启动:
Running with gitlab-runner 10.8.0 (079aad9e)
on docker-runner 8a1645e0
Using Docker executor with image teamdesk/toolbox:7.2 ...
Starting service drush/drush:8 ...
Pulling docker image drush/drush:8 ...
Using docker image sha256:646ef48a637011d5bf97ed3021e280d583aa966e63fceea478d9be8dc5ea2902 for drush/drush:8 ...
Waiting for services to be up and running...
*** WARNING: Service runner-8a1645e0-project-35-concurrent-0-drush__drush-0 probably didn't start properly.
Health check error:
exit code 1
Health check container logs:
2019-03-07T16:51:12.703254779Z No HOST or PORT
如果我尝试以下操作:
services:
- name: drush/drush:8
command: ["drush", "config-import -y"]
我得到:
Running with gitlab-runner 10.8.0 (079aad9e)
on docker-runner e0df35ff
Using Docker executor with image teamdesk/toolbox:7.2 ...
Starting service drush/drush:8 ...
Pulling docker image drush/drush:8 ...
Using docker image sha256:646ef48a637011d5bf97ed3021e280d583aa966e63fceea478d9be8dc5ea2902 for drush/drush:8 ...
Waiting for services to be up and running...
*** WARNING: Service runner-e0df35ff-project-35-concurrent-0-drush__drush-0 probably didn't start properly.
Health check error:
exit code 1
Health check container logs:
2019-03-08T08:37:07.739033180Z No HOST or PORT
Service container logs:
2019-03-08T08:37:07.398595623Z The drush command 'drush config-import -y' could not be found. Run [error]
2019-03-08T08:37:07.398686996Z `drush cache-clear drush` to clear the commandfile cache if you have
2019-03-08T08:37:07.398695300Z installed new extensions.
因为我需要 运行 drush updatedb
和 drush config-import
在生产服务器上部署之前,我想在 gitlab 中使用 drush 作为服务- ci.yml.
drush config-import -y
是一次性命令;一旦它的工作完成,它 运行s 的过程就会停止。所以它不是服务,你不能把它放在 .gitlab-ci.yml
的 service:
部分。 Gitlab CI Runner 希望这些服务永远不会停止,并且如果其中一项服务死亡,将会抱怨。
你能做什么?
运行 drush
在 script:
部分。为此,您必须确保 docker 图像 tetraweb/php:7.1
具有可用的 drush
命令。
image: tetraweb/php:7.1 ## this image must have drush available
script:
- drush config-import -y
- drush updatedb
...