【问题标题】:execute commands on my local server before execute the stages on docker - gitlab-ci.yml在 docker 上执行阶段之前在我的本地服务器上执行命令 - gitlab-ci.yml
【发布时间】:2016-11-01 15:34:33
【问题描述】:

我有这个 gitlab-ci.yml

stages:
  - test

test_ahpi:
  stage: test
  image: "ahgora/alpine-test-node"
  script:
   - cd ${CI_PROJECT_DIR}/api; npm install --unsafe-perm
   - cd ${CI_PROJECT_DIR}/api; node_modules/.bin/gulp build-test

test_php:
  stage: test
  image: "ahgora/alpine-test-php"
  script:
   - cd ${CI_PROJECT_DIR}/; make test

但我之前想在本地服务器上做一些步骤,所以我不需要手动运行一些步骤。

有没有办法在我的本地服务器上执行命令,然后在 gitlab-ci.yml 上执行阶段??

我想我可以做类似下面的事情,但是我得到错误因为没有任何定义的图像到这个步骤。(但我想在 shell 中运行它而不是在这个特定阶段的 docker 中)。

stages:
  - prepare
  - test

docker:
  stage: prepare
  script:
   - docker run -d --name lookupd nsqio/nsq /nsqlookupd
   - docker run --name mongo -d mongo
   - docker run -d --link lookupd:lookupd --name nsqd nsqio/nsq /nsqd --broadcast-address=lookupd --lookupd-tcp-address=lookupd:4160
   - docker run --name redis -d redis    

test_ahpi:
  stage: test
  image: "ahgora/alpine-test-node"
  script:
   - cd ${CI_PROJECT_DIR}/api; npm install --unsafe-perm
   - cd ${CI_PROJECT_DIR}/api; node_modules/.bin/gulp build-test

test_php:
  stage: test
  image: "ahgora/alpine-test-php"
  script:
   - cd ${CI_PROJECT_DIR}/; make test

感谢您的宝贵时间。

【问题讨论】:

    标签: continuous-integration gitlab devops gitlab-ci


    【解决方案1】:

    如果你不想使用 docker 作为 gitlab-runner ,那么你可以在特定阶段指定 tag 并指定 shell 作为执行器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-12
      • 2012-05-24
      • 1970-01-01
      • 2021-09-17
      • 2020-07-06
      相关资源
      最近更新 更多