如何使用Docker在主机上拉项目?

时间:2017-11-14 01:18:24

标签: docker gitlab gitlab-ci gitlab-ci-runner

我正在了解gitlab-ci.yml并且我开始阅读environments这让我想知道,是否可以访问主机上的文件夹并执行git pull命令在deploy阶段?

image: php:5.6

# The folders we should cache
cache:
  paths:
  - vendor/

before_script:

# Install git, the php image doesn't have installed
- apt-get update -yqq
- apt-get install git mysql-client -yqq

# Install mysql driver
- docker-php-ext-install pdo_mysql

# Install composer
- curl -sS https://getcomposer.org/installer | php

# Install all project dependencies
- php composer.phar install

services:
    - mysql

variables:
    MYSQL_DATABASE: test
    MYSQL_ROOT_PASSWORD: root

test:
    stage: test
    script:
        - echo "CREATE DATABASE IF NOT EXISTS test;" | mysql --user=root --password="${MYSQL_ROOT_PASSWORD}" --host=mysql
        - mysql --user=root --password="${MYSQL_ROOT_PASSWORD}" --host=mysql test < tests/assets/test.sql
        - php composer.phar tests

deploy_staging:
    stage: deploy
    script:
        - echo "Deploying to staging server..."
    environment:
        name: staging
        url: http://staging.example.com
    only:
        - master

基本上我的脚本都是导入数据库文件并执行PDO服务的测试。只是随机测试,了解CI。

现在而不是:

- echo "Deploying to staging server..."

我想知道如何实现以下目标:

- cd /path/on/host/machine/to/repository
- git pull

如果没有,是否有其他方法可以完成我想做的事情?

0 个答案:

没有答案