如何在gitlab-ci.yml中将drush用作服务?

时间:2019-03-07 16:55:03

标签: docker gitlab drupal-8

根据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 updatedbdrush config-import,所以我想在 gitlab-ci.yml 中将drush用作服务。

1 个答案:

答案 0 :(得分:1)

drush config-import -y是一次性命令;工作完成后,它将停止运行。因此,它不是服务,您不能将其放在service:的{​​{1}}部分中。 Gitlab CI Runner希望这些服务永远不会停止,并且会抱怨其中一项服务死了。

你能做什么?

运行.gitlab-ci.yml部分中的drush。为此,您必须确保Docker映像script:具有tetraweb/php:7.1命令可用。

drush